nemorize / hanji
A lightweight static site generator for PHP.
Requires
- php: ^8.5
- amphp/http-server: ^3.4
- amphp/websocket-server: ^4.0
- illuminate/container: ^13.0
- illuminate/events: ^13.0
- illuminate/filesystem: ^13.0
- illuminate/support: ^13.0
- illuminate/view: ^13.0
- league/commonmark: ^2.8
- nikic/php-parser: ^5.7
- symfony/console: ^7.4
- symfony/filesystem: ^7.4
- symfony/finder: ^7.4
- symfony/process: ^8.0
- symfony/yaml: ^7.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
- scssphp/scssphp: ^2.1
Suggests
- ext-ffi: Enables native file watching on macOS, Linux and Windows.
- scssphp/scssphp: ^2.1 enables the optional PHP SCSS build plugin.
Provides
None
Conflicts
None
Replaces
None
README
A lightweight static site generator for PHP 8.5, with Blade, PHP and Markdown pages.
Install
composer require nemorize/hanji:^0.1
php vendor/bin/hanji init .
php vendor/bin/hanji build
The starter creates hanji.php and a site/ directory. Deploy the generated
_site/ directory to a static host.
php vendor/bin/hanji serve php vendor/bin/hanji clean
The development server supports CSS updates, live reload and build error overlays. Native file watching uses PHP FFI when available and falls back to polling.
Configure
hanji.php returns a Hanji\Config instance. Paths are relative to its directory.
<?php use Hanji\Config; return (new Config()) ->input('site') ->output('_site') ->title('My site') ->baseUrl('https://example.com') ->timezone('Asia/Seoul');
Blade (.blade.php), PHP (.php) and Markdown (.md) pages become static HTML.
Other files are copied, including hidden and unreferenced files. Files whose names
start with @ are reserved for layouts, data, shared templates and other inputs;
they do not produce standalone output.
Use @layout.blade.php and Hanji::children() for layouts, and @meta([...])
in Blade or YAML front matter in Markdown for page metadata. Relative HTML and
CSS asset references follow output mappings and the configured basePath.
Optional SCSS
composer require scssphp/scssphp:^2.1
Register new Hanji\Plugin\Build\ScssBuildPlugin() with Config::plugin() to
compile SCSS. Without the plugin, SCSS files are copied unchanged.
CI and updates
Commit your site's composer.json and composer.lock. A build needs only:
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader php vendor/bin/hanji build
Run composer update nemorize/hanji to adopt a new compatible release and commit
the updated lock file. No separate Hanji checkout is needed.
Development and releases
composer install composer check
Release versions come from Git tags such as v0.1.0. Keep Console::VERSION in
sync with the release, run the checks, and push the tag. Packagist imports tags
from the registered GitHub repository; do not add a version field to
composer.json.