2017 © Pedro Peláez
 

library phpillip

PHP Static Site Generator

image

phpillip/phpillip

PHP Static Site Generator

  • Sunday, September 4, 2016
  • by Tom32i
  • Repository
  • 3 Watchers
  • 25 Stars
  • 130 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 3 Open issues
  • 8 Versions
  • 3 % Grown

The README.md

Phpillip is Hugo's cousin., (*1)

What

Phpillip is static website generator written in PHP and powered by Silex and Symfony components., (*2)

It basically dumps your Silex application to static HTML files in a /dist folder., (*3)

The result directory is meant to be served by an HTTP Server like apache and nginx or published to static website services like Github Pages., (*4)

It's particularly fit for blogging, documentation and showcase., (*5)

How

Phpillip is a Silex application., (*6)

The build process: - Loop through all declared routes in the Application - Load content associated with the route (if any) from file - Call each route with its content in a Request - Dump the Response content in a file, (*7)

It supports as many format as you need., (*8)

It uses the powerful Twig engine for templating., (*9)

Why

Phpillip is meant to be:, (*10)

  • Highly extensible
  • Friendly with Symfony developers
  • Clear, simple and clean

Getting started

Get your static website:, (*11)

  1. Bootstrap a Phpillip project
  2. Write your content
  3. Declare your routes and controllers
  4. Provide templates
  5. Build the static website

1. Bootstrap

To bootstrap a new Phpillip project:, (*12)

``` bash composer create-project phpillip/phpillip-standard my_app cd my_app, (*13)


### 2. Write content Write your content file `[my-content-slug].[format]` in `src/Resources/data/[my-content-type]/`: __Example__ `src/Resources/data/article/why-use-phpillip.md`:

title: Why use Phpillip?

Why use Phpillip

Why not!, (*14)


### 3. Declare routes and controllers Phpillip is a Silex application, so you can declare a route and its controller [the same way you would in Silex](http://silex.sensiolabs.org/doc/usage.html#routing): A closure: ``` php $this->get('/', function () { return []; })->template('index.html.twig');

Your own controller class in 'src/Controller':, (*15)

``` php $this->get('/blog', 'Controller\BlogController::index');, (*16)


A controller service (here the Phpillip content controller service): ``` php $this->get('/blog/{post}', 'content.controller:show')->content('post');

Phpillip gives you many helpers to automate content loading for your routes., (*17)

4. Provide templates

Write the Twig templates corresponding to your routes and controllers in src/Resources/views/, (*18)

If you use the default Phpillip routes and controller, you'll need to provide:, (*19)

The list template:, (*20)

  • File: [my-content-type]/index.html.twig.
  • Variables: An array of contents, named [content-type]s.

``` twig {% extends 'base.html.twig' %} {% block content %} {% for article in articles %} {{ article.title }} {% endfor %} {% endblock %}, (*21)


The single content page template: * _File:_ `[my-content-type]/show.html.twig`. * _Variables:_ The content as an associative array, named `[content-type]`. ``` twig {% extends 'base.html.twig' %} {% block content %} {{ article.content }} {% endblock %}

5. Build

Build the static files to /dist with the Phpillip build command:, (*22)

bin/console phpillip:build

, (*23)

You're done!, (*24)

Going further:

About Phpillip's features: - Helpers: Param Converters and other route shortcuts - Sitemap, (*25)

About content:, (*26)

About controllers:, (*27)

About the console:, (*28)

Contribution

Any kind of contribution is very welcome!, (*29)

Directory structure

# Sources directory
src/
    # Your Silex Application in which your declare routes, services, ...
    Application.php

    # Your controller classes (optional)
    # This is only a recommandation, you can put controllers wherever you like
    /Controller
        MyController.php

    # Resources
    /Resources

        # Configuration files directory
        config/
            # Phpillip configuration
            config.yml

        # Content directory
        data/
            # Create a directory for each content type
            post/
                # Your 'post' contents goes here
                my-first-post.md
                a-post-in-json.json

        # Public directory
        public/
            # All public directory content will be exposed in 'dist'
            css/
                style.css

        # Views directory
        views/
            # Your twig templates
            base.html.twig
            blog/
                index.html.twig
                show.html.twig

# Destination directory
dist/
    # The static files will be dumped in here

The Versions

10/02 2016

dev-microkernel

dev-microkernel http://phpillip.github.io/

PHP Static Site Generator

  Sources   Download

MIT

The Requires