Coder Social home page Coder Social logo

phanstatic's Introduction

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:

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.

phanstatic's People

Contributors

terdelyi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.