2017 © Pedro Peláez
 

vendor build

Static PHP website builder

image

jeremyharris/build

Static PHP website builder

  • Tuesday, August 8, 2017
  • by jeremyharris
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Build
Status, (*1)

Build

A little static site generator, built specifically to build little sites with blog posts., (*2)

Installation

composer require jeremyharris/build, (*3)

Features

  • Stupid dumb easy setup (no config files)
  • Concatenates assets
  • Builds only modified files
  • Some tools for basic blog functionality
  • Flexible-ish

Usage

$build = new \JeremyHarris\Build\Build('/path/to/site_target', 'path/to/build_target');
$build->build();

Only files that have been modified since you last built will be built. You can optionally pass true to build() to force build all files. You can then get full paths to newly built files:, (*4)

$newlyBuiltFiles = $build->getBuiltFiles();
// now deploy them!

If you want to manually add build files that aren't within the expected structure, you can do so:, (*5)

// add a file to the build root
$build->addFileToBuild('/full/path/to/file.html');
// add a file to a new directory within the build
$build->addFileToBuild('/full/path/to/file.html', 'some/directory');
// render a file as a view (wrap it in the layout)
$build->addFileToBuild('/path/to/my.php', 'some/directory', true);
$build->addFileToBuild('/path/to/my.md', '/', true);

Blogging

Some blogging functionality is provided in the \JeremyHarris\Build\Blog class. It assumes a YYYY/MM structure. The Blog class is helpful for building an archive page or getting the latest post. Items returned are \JeremyHarris\Build\Blog\Post objects that contain some helpful methods., (*6)

$Blog = new Blog('/path/to/site_target');
$latest = $Blog->getLatest();
$allPosts = $Blog->getPosts();

$linkToLatest = $latest->link();
$latestTitle = $latest->title();

RSS

To create an RSS feed, you must tell the builder that you want one and pass some required settings that the feed needs in order to generate:, (*7)

$build = new \JeremyHarris\Build\Build('/path/to/site_target', 'path/to/build_target');
$build->addRss('My Blog', 'https://example.com', 'Description of site');
$build->build();

The generator will then automatically create a basic RSS feed for you. The file will be in the root of your built site. Only the last 20 blog posts will be included in the feed., (*8)

Site target structure

The site target should have a layout like the one below. Anything in /webroot is copied directly to webroot, allowing flexibility in not using views. Items in /views are wrapped in layout.php and placed into the directories they reside in. Views can be php or markdown., (*9)

Titles are assumed from the filename slug, so interesting-article-about-things.md is titled "Interesting Article About Things"., (*10)

site
|_ views
|  |
|  |_ about.php
|  |_ contact.md
|     |_ sub
|        |_ article.php
|_ assets
| |_ css
| |  |_ css1.css
| |  |_ css2.css
| |
| |_ js
|    |_ script1.js
|    |_ script2.js
|
|_ webroot
|  |_ robots.txt
|  |_ fonts
|     |_ font1.otf
|
|_ layout.php

And builds it into a site like this:, (*11)

build
|_ fonts
|  |_ font1.otf
|
|_ sub
|  |_ article.html
|
|_ styles.css
|_ scripts.js
|- rss.xml
|_ about.html
|_ contact.html
|_ robots.txt

Note rss.xml will only exist if you added an RSS feed before build., (*12)

Example site

The Versions

08/08 2017

dev-master

9999999-dev

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires

20/07 2017

0.5

0.5.0.0

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires

23/12 2015

0.4

0.4.0.0

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires

23/12 2015

dev-develop

dev-develop

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires

28/09 2015

dev-plates

dev-plates

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires

24/03 2015

0.3

0.3.0.0

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires

09/03 2015

0.2

0.2.0.0

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires

06/03 2015

0.1

0.1.0.0

Static PHP website builder

  Sources   Download

MIT

The Requires

 

The Development Requires