gallib / pssg
PHP Static Site Generator
Requires
- php: ^8.5
- league/commonmark: ^2.10
- symfony/console: ^8.1
- symfony/process: ^8.1
- symfony/yaml: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- pestphp/pest: ^5.2
- phpstan/phpstan: ^2.2
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
PSSG (PHP Static Site Generator) is a lightweight static site generator written in PHP.
It converts Markdown files into static HTML pages using PHP templates.
Requirements
- PHP 8.5 or later
- Composer
Installation
Create a new directory for your website and initialize a Composer project:
mkdir my-site
cd my-site
composer init
Install PSSG:
composer require gallib/pssg
Initialize the site:
vendor/bin/pssg init
PSSG creates the following structure:
my-site/
├── assets/
├── pages/
│ └── index.md
├── templates/
│ └── default.php
├── pssg.yml
└── vendor/
Build
Generate the static website with:
vendor/bin/pssg build
The generated files are written to the site/ directory by default.
Development server
Start the development server with:
vendor/bin/pssg serve
PSSG watches the pages, templates and assets directories and automatically rebuilds the website when a file changes.
By default, the development server is available on port 8000.
Pages
Pages are Markdown files stored in the pages/ directory.
For example:
# Hello PSSG
Welcome to my website.
The directory structure is preserved when the website is generated.
For example:
pages/
├── index.md
└── about/
└── index.md
generates:
site/
├── index.html
└── about/
└── index.html
Front matter
Pages can define additional data using YAML front matter:
--- title: About author: John Doe --- # About This is the about page.
Front matter values are available as variables inside the PHP template.
Templates
Templates are PHP files stored in the templates/ directory.
The default template is:
templates/default.php
A page can use another template with its front matter:
--- template: article.php title: My article ---
Templates can access the generated page content with:
<?= $content ?>
The configured site name is available with:
<?= $siteName ?>
Assets
Files stored in assets/ are copied to:
site/assets/
The directory structure is preserved.
Configuration
PSSG is configured using pssg.yml:
site: name: My PSSG Site directories: pages: pages templates: templates assets: assets output: site server: host: 0.0.0.0 port: 8000
Commands
vendor/bin/pssg init vendor/bin/pssg build vendor/bin/pssg serve
License
PSSG is released under the MIT License.