定制 phpillip/phpillip 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpillip/phpillip

最新稳定版本:v1.0.5

Composer 安装命令:

composer require phpillip/phpillip

包简介

PHP Static Site Generator

README 文档

README

Phpillip is Hugo's cousin.

What

Phpillip is static website generator written in PHP and powered by Silex and Symfony components.

It basically dumps your Silex application to static HTML files in a /dist folder.

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.

It's particularly fit for blogging, documentation and showcase.

How

Phpillip is a Silex application.

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

It supports as many format as you need.

It uses the powerful Twig engine for templating.

Why

Phpillip is meant to be:

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

Getting started

Get your static website:

  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:

composer create-project phpillip/phpillip-standard my_app
cd my_app

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!

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:

A closure:

$this->get('/', function () { return []; })->template('index.html.twig');

Your own controller class in 'src/Controller':

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

A controller service (here the Phpillip content controller service):

$this->get('/blog/{post}', 'content.controller:show')->content('post');

Phpillip gives you many helpers to automate content loading for your routes.

4. Provide templates

Write the Twig templates corresponding to your routes and controllers in src/Resources/views/

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

The list template:

  • File: [my-content-type]/index.html.twig.
  • Variables: An array of contents, named [content-type]s.
{% extends 'base.html.twig' %}
{% block content %}
    {% for article in articles %}
        <a href="{{ path('article', {article: article.slug}) }}">
            {{ article.title }}
        </a>
    {% endfor %}
{% endblock %}

The single content page template:

  • File: [my-content-type]/show.html.twig.
  • Variables: The content as an associative array, named [content-type].
{% extends 'base.html.twig' %}
{% block content %}
    {{ article.content }}
{% endblock %}

5. Build

Build the static files to /dist with the Phpillip build command:

bin/console phpillip:build

You're done!

Going further:

About Phpillip's features:

About content:

About controllers:

About the console:

Contribution

Any kind of contribution is very welcome!

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

统计信息

  • 总下载量: 164
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-01