PHP code example of jeremyharris / build

1. Go to this page and download the library: Download jeremyharris/build library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeremyharris / build example snippets


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

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

// 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);

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

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

$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();

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