terdelyi / phanstatic
A simple, lightweight and CLI based static site generator
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
pkg:composer/terdelyi/phanstatic
Requires
- php: >=8.2
- league/commonmark: ^2.4
- spatie/yaml-front-matter: ^2.0
- symfony/console: ^7.1
- symfony/filesystem: ^7.0
- symfony/finder: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.6
- phpstan/phpstan: ^2.1
- phpstan/phpstan-mockery: ^2.0
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2025-10-23 20:39:17 UTC
README
Phanstatic is a dead simple, modern, lightweight, CLI based static site generator written in PHP. There are no frameworks or template engines, just simple pages written in pure PHP code and markdown files. During the building process, all of your content is transformed into static HTML files, ready to deploy or upload to your server.
Install
To create a new project just run:
composer create-project terdelyi/phanstatic
Build
To build static files to the dist folder from the files placed inside the content directory run the following
command in your root folder:
php ./vendor/bin/phanstatic build
Preview
To preview the dist folder quickly in a browser:
php ./vendor/bin/phanstatic preview
This will start PHP's built-in server at localhost with port 8000 and make the files from the dist available in a
browser.
You can override the default host (--host) and the port (--port) settings if necessary.
Configuration
You can place a configuration file under content/config.php which must return a ConfigBuilder object like this:
use Terdelyi\Phanstatic\Models\Config; use Terdelyi\Phanstatic\Models\CollectionConfig; return new Config( baseUrl: (string) getenv('BASE_URL'), title: 'My super-fast static site', collections: [ 'posts' => new CollectionConfig( title: 'Posts', slug: 'posts', pageSize: 10 ), ], );
If no config.php file exist the builder will use the default settings. To explore settings your IDE should guide you by
offering the available properties with types.
Content basics
Structuring the content is simple. The content folder is where your files live:
content/pages: This is where you put your.phpfiles.content/collections: This is where you put your.mdfiles under subdirectories named as your collection key.content/assets: Any of these files will be published underdist/assets. It can be.js,.cssor any type of images.
Example project structure
├── content
│ ├── assets
│ │ ├── images
│ │ ├── css
│ │ ├── js
│ ├── collections
│ │ ├── posts
│ │ │ ├── my-first-blog-post.md
│ ├── pages
│ │ ├── about.php
│ │ ├── index.php
│ ├── config.php
├── composer.json
├── composer.lock
If you create a folder under collections you must add it as a collection to your config file, unless you're going
to have Configuration for collection 'Collection' is missing error.
