-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
322 lines (303 loc) · 14.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Phpillip</title>
<meta name="description" content="Phpillip documentation">
<meta name="author" content="Thomas Jarrand">
<meta name="twitter:card" content="summary">
<meta name="twitter:url" content="http://phpillip.github.io/">
<meta name="twitter:site" content="@tom32i">
<meta name="twitter:title" content="Phpillip">
<meta name="twitter:description" content="Phpillip: A static website generator for #Symfony developers">
<meta property="twitter:image" content="http://phpillip.github.io/phpillip.png">
<link rel="canonical" href="http://phpillip.github.io/">
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<a href="https://github.com/Phpillip/phpillip"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork Phpillip on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a>
<div id="#top" class="container">
<div class="row">
<div class="content col-sm-9">
<h1 id="-http-phpillip-github-io-phpillip-svg-"><img src="http://phpillip.github.io/phpillip.svg" alt="" target="_blank" /></h1>
<blockquote>
<p>Phpillip is <a href="https://gohugo.io/" target="_blank">Hugo</a>'s cousin.</p>
</blockquote>
<h2 id="what">What</h2>
<p>Phpillip is static website generator written in PHP and powered by <a href="http://silex.sensiolabs.org/" target="_blank">Silex</a> and <a href="http://symfony.com/doc/current/components/index.html" target="_blank">Symfony components</a>.</p>
<p>It basically dumps your Silex application to static HTML files in a <code>/dist</code> folder.</p>
<p>The result directory is meant to be served by an HTTP Server like <a href="http://apache.org" target="_blank">apache</a> and <a href="http://www.nginx.com" target="_blank">nginx</a> or published to static website services like <a href="https://pages.github.com/" target="_blank">Github Pages</a>.</p>
<p><em>It's particularly fit for <strong>blogging</strong>, <strong>documentation</strong> and <strong>showcase</strong>.</em></p>
<h2 id="how">How</h2>
<p>Phpillip is a <a href="http://silex.sensiolabs.org/" target="_blank">Silex</a> application.</p>
<p>The <strong>build process</strong>:</p>
<ul>
<li>Loop through all declared <em>routes</em> in the Application</li>
<li>Load content associated with the route (if any) from file</li>
<li>Call each route with its content in a <em>Request</em></li>
<li>Dump the <em>Response</em> content in a file</li>
</ul>
<p>It supports as many format as you need.</p>
<p>It uses the powerful <a href="http://twig.sensiolabs.org/" target="_blank">Twig</a> engine for templating.</p>
<h2 id="why">Why</h2>
<p>Phpillip is meant to be:</p>
<ul>
<li>Highly <strong>extensible</strong></li>
<li>Friendly with <strong>Symfony</strong> developers</li>
<li>Clear, simple and clean</li>
</ul>
<h2 id="getting-started">Getting started</h2>
<p>Get your static website:</p>
<ol>
<li>Bootstrap a Phpillip project</li>
<li>Write your content</li>
<li>Declare your routes and controllers</li>
<li>Provide templates</li>
<li>Build the static website</li>
</ol>
<h3 id="-bootstrap">1. Bootstrap</h3>
<p>To bootstrap a new <a href="https://github.com/Phpillip/phpillip" target="_blank">Phpillip</a> project:</p>
<pre><code class="language-bash"><span></span>composer create-project phpillip/phpillip-standard my_app
<span class="nb">cd</span> my_app
</code></pre>
<h3 id="-write-content">2. Write content</h3>
<p>Write your content file <code>[my-content-slug].[format]</code> in <code>src/Resources/data/[my-content-type]/</code>:</p>
<p><strong>Example</strong> <code>src/Resources/data/article/why-use-phpillip.md</code>:</p>
<pre><code>---
title: Why use Phpillip?
---
# Why use Phpillip
Why not!</code></pre>
<h3 id="-declare-routes-and-controllers">3. Declare routes and controllers</h3>
<p>Phpillip is a Silex application, so you can declare a route and its controller <a href="http://silex.sensiolabs.org/doc/usage.html#routing" target="_blank">the same way you would in Silex</a>:</p>
<p>A closure:</p>
<pre><code class="language-php"><span></span><span class="cp"><?php</span>
<span class="nv">$this</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span> <span class="k">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="p">[];</span> <span class="p">})</span><span class="o">-></span><span class="na">template</span><span class="p">(</span><span class="s1">'index.html.twig'</span><span class="p">);</span>
</code></pre>
<p>Your own controller class in 'src/Controller':</p>
<pre><code class="language-php"><span></span><span class="cp"><?php</span>
<span class="nv">$this</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'/blog'</span><span class="p">,</span> <span class="s1">'Controller\\BlogController::index'</span><span class="p">);</span>
</code></pre>
<p>A controller service (here the Phpillip content controller service):</p>
<pre><code class="language-php"><span></span><span class="cp"><?php</span>
<span class="nv">$this</span><span class="o">-></span><span class="na">get</span><span class="p">(</span><span class="s1">'/blog/{post}'</span><span class="p">,</span> <span class="s1">'content.controller:show'</span><span class="p">)</span><span class="o">-></span><span class="na">content</span><span class="p">(</span><span class="s1">'post'</span><span class="p">);</span>
</code></pre>
<p>Phpillip gives you <a href="/feature-helpers">many helpers</a> to automate content loading for your routes.</p>
<h3 id="-provide-templates">4. Provide templates</h3>
<p>Write the Twig templates corresponding to your routes and controllers in <code>src/Resources/views/</code></p>
<p>If you use the default Phpillip routes and controller, you'll need to provide:</p>
<p>The list template:</p>
<ul>
<li><em>File:</em> <code>[my-content-type]/index.html.twig</code>.</li>
<li><em>Variables:</em> An array of contents, named <code>[content-type]s</code>.</li>
</ul>
<pre><code class="language-twig"><span></span><span class="cp">{%</span> <span class="k">extends</span> <span class="s1">'base.html.twig'</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">block</span> <span class="nv">content</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">article</span> <span class="k">in</span> <span class="nv">articles</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <a href="</span><span class="cp">{{</span> <span class="nv">path</span><span class="o">(</span><span class="s1">'article'</span><span class="o">,</span> <span class="o">{</span><span class="nv">article</span><span class="o">:</span> <span class="nv">article.slug</span><span class="o">})</span> <span class="cp">}}</span><span class="x">"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">article.title</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> </a></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span><span class="x"></span>
</code></pre>
<p>The single content page template:</p>
<ul>
<li><em>File:</em> <code>[my-content-type]/show.html.twig</code>.</li>
<li><em>Variables:</em> The content as an associative array, named <code>[content-type]</code>.</li>
</ul>
<pre><code class="language-twig"><span></span><span class="cp">{%</span> <span class="k">extends</span> <span class="s1">'base.html.twig'</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">block</span> <span class="nv">content</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">article.content</span> <span class="cp">}}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span><span class="x"></span>
</code></pre>
<h3 id="-build">5. Build</h3>
<p>Build the static files to <code>/dist</code> with the Phpillip build command:</p>
<pre><code>bin/console phpillip:build</code></pre>
<p><img src="http://phpillip.github.io/build.gif" alt="" target="_blank" /></p>
<p>You're done!</p>
<h2 id="going-further-">Going further:</h2>
<p>About Phpillip's <strong>features</strong>:</p>
<ul>
<li><a href="/feature-helpers">Helpers: Param Converters and other route shortcuts</a></li>
<li><a href="/feature-sitemap">Sitemap</a></li>
</ul>
<p>About <strong>content</strong>:</p>
<ul>
<li><a href="/content-formats">Supported formats</a></li>
<li><a href="/content-markdown">Markdown</a></li>
<li><a href="/content-retrieving-content">Retrieving content</a></li>
<li><a href="/content-property-handlers">Property handlers</a></li>
</ul>
<p>About <strong>controllers</strong>:</p>
<ul>
<li><a href="/controller-content">Phpillip's default content controller</a></li>
<li><a href="/controller-custom">Custom controller classes</a></li>
<li><a href="/controller-format">Specifying output format</a></li>
<li><a href="/controller-template">Template Resolution</a></li>
</ul>
<p>About the <strong>console</strong>:</p>
<ul>
<li><a href="/console-commands">Phpillip's Console</a></li>
</ul>
<h2 id="contribution">Contribution</h2>
<p>Any kind of <a href="/more-contribution">contribution</a> is very welcome!</p>
<h2 id="directory-structure">Directory structure</h2>
<pre><code># 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
</code></pre>
</div>
<div class="side-bar col-sm-3">
<a id="logo" class="logo" href="/">
<img alt="Phpillip" title="Phpillip" src="/phpillip.svg">
</a>
<div class="menu">
<h5 class="title">
CONSOLE
</h5>
<ul class="category nav nav-pills nav-stacked">
<li class="nav-item">
<a class="nav-link " href="/console-commands">
Phpillip's console
</a>
</li>
</ul>
<h5 class="title">
CONTENT
</h5>
<ul class="category nav nav-pills nav-stacked">
<li class="nav-item">
<a class="nav-link " href="/content-formats">
Supported formats
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/content-markdown">
Markdown
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/content-property-handlers">
Property Handlers
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/content-retrieving-content">
Retrieving content
</a>
</li>
</ul>
<h5 class="title">
CONTROLLER
</h5>
<ul class="category nav nav-pills nav-stacked">
<li class="nav-item">
<a class="nav-link " href="/controller-content">
Content Controller
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/controller-custom">
Custom Controller
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/controller-format">
Route format
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/controller-template">
Template resolution
</a>
</li>
</ul>
<h5 class="title">
FEATURE
</h5>
<ul class="category nav nav-pills nav-stacked">
<li class="nav-item">
<a class="nav-link " href="/feature-helpers">
Route Helpers
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/feature-sitemap">
Sitemap
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/feature-twig">
Twig utils
</a>
</li>
</ul>
<h5 class="title">
MORE
</h5>
<ul class="category nav nav-pills nav-stacked">
<li class="nav-item">
<a class="nav-link " href="/more-about">
About Phpillip
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="/more-contribution">
Contributing
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="footer container">
<a class="back-to-top" href="#top">
Back to top
</a>
</footer>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-7324372-8', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>