Skip to content

TAR-IT/phpages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPages - a static website generator using PHP

This is a handy little tool for creating static sites using PHP. It is a consolidation of different snippets and ideas that I changed to my needs. My goal is to create a lightweight static site generator with SEO Tag implementations and multilanguage support.

Table of Contents

  1. Technologies Used
  2. Getting Started
  3. License

Technologies Used

Getting Started

Installation

  1. Download & install PHP.
  2. Download & install Composer.
  3. Fork/clone the repository or download the repository as a .zip folder and unzip it.

Usage

  1. Start building your pages
    • you can place your pages in "/src/pages/" - the build script will automatically use all .html files inside of this directory
    • if you want to build a multilanguage website, you can use the $languages variable in the config.php to define country codes for the subdirectories (e.g. "en" for english or "de" for german) - the subdirectories will automatically be generated
  2. Use templates and includes
    • use templates to extend your pages with predefined html (default directory is "src/templates/")
      • pages can extend a template by calling the following function in your page:
        startExtend(string $template, array $variables)
        endExtend()
      • This will extend the content of your page with the corresponding template file. Example usage in your .html file (where "default.html" is a template in "src/templates/"):
        <?php startExtend("default.html", []); ?>
            <main>
                <h1>This is the page content</h1>
            </main>
        <?php endExtend(); ?>
    • use includes to include blocks of html in your pages (default directory is "src/includes/")
      • includes can be used to extend pages, templates or other includes:
        startInclude(string $include, array $variables, bool $print)
      • This will extend the content of your page with the corresponding template file. Example usage in your .html file (where "nav.html" is a file in "/src/includes/"):
        <?php includePart("nav.html", []); ?> 
  3. Use enviroment variables for staging and production environments
    • the files "env.prod.php" and "env.stage.php" are used for enviromental variables
    • building the website will default to "env.stage.php" - using the "--prod" tag while building will switch to production variables ( in "env.prod.php")
  4. Generate the static sites by using the build script via the terminal - the output files will be placed in "public/"
    php build.php # for staging variables
    or
    php build.php --prod # for production variables 

Multilanguage Support

To do.

Testing

No tests have been applied yet.

To-Dos

  • Multilanguage support
    • support for language specific includes
    • support for language specific variables
  • SEO generator

Contributing

Contributing is not intendet yet.

License

This project is licensed under GNU General Public License v3.

About

PHPages - a simple PHP-powered Static Hypertext Generator.

Resources

License

Stars

Watchers

Forks

Releases

No releases published