Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/terdelyi/phanstatic
A simple, lightweight and CLI based static site generator written in PHP
https://github.com/terdelyi/phanstatic
jamstack php static-site-generator
Last synced: 3 months ago
JSON representation
A simple, lightweight and CLI based static site generator written in PHP
- Host: GitHub
- URL: https://github.com/terdelyi/phanstatic
- Owner: terdelyi
- License: mit
- Created: 2024-03-18T17:34:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T15:43:29.000Z (4 months ago)
- Last Synced: 2024-09-29T14:01:26.866Z (3 months ago)
- Topics: jamstack, php, static-site-generator
- Language: PHP
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Phanstatic 👷
==========Phanstatic is a simple, 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.## Install
To create a new project just run:
```
composer create-project terdelyi/phanstatic:dev-develop
```## Build
To build static files from your `content` directory to the `dist` folder run the following command in your root folder:
```
php ./vendor/bin/phanstatic build
```## Preview
To preview your build 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
As a starter all you need is a `content/pages` directory in the root of your project which contains `.php` files.
Optionally, you can also place a configuration file under `content/config.php` which must return a `Config` object like
this:```php
use Terdelyi\Phanstatic\Config\ConfigBuilder;return (new ConfigBuilder)
->setBaseUrl(getenv('BASE_URL'))
->setTitle('My super-fast static site')
->addCollection(
key: 'posts',
title: 'Posts',
slug: 'posts',
pageSize: 10
)
->build();
```## Example content structure
None of these files are mandatory. Phanstatic and its builders will look for the existing folders and configuration
and use them if they're available.```
├── content
│ ├── assets
│ │ ├── images
│ │ ├── css
│ │ ├── js
│ ├── collections
│ │ ├── posts
│ │ │ ├── my-first-blog-post.md
│ ├── pages
│ │ ├── about.php
│ │ ├── index.php
│ ├── config.php
├── composer.json
├── composer.lock
```The contents of the assets folder will be copied to the `dist/assets` folder on build as it is and will be available
from the url `/assets`.## Contributing
Bugfixes and feature requests are highly welcome, but this package is in its early stages, and I'm planning to add any
new features carefully.