A light weight, extensible template engine designed with separation of duties in mind, allowing both back-end developers and designers to complete their work independently. It supports:
- Standardized
<s:...)
template tags providing short hand for larger HTML snippets, interopability across themes, plus additional PHP functionality. - Easily develop your own functional <s:...> template tags in addition to default set.
- Easy loading of dynamic content such as breadcrumbs, social media links, and placeholders.
- Multiple themes based on template file location (eg. different themes for public site, admin panel, and client area).
- PSR6 caching, including configuration for no-cache pages and tags, and support for optional "cache" attribute within tags.
- Optional auto-routing, automatically renders the appropriate template corresponding to the URI being viewed.
- Optional per-template PHP class, which is automatically executed upon rendering the template providing bridge between templates and back-end application.
- Developed with designers in mind, allowing them to work independently and without the need to navigate back-end software code.
- Built-in support for Cluster, which makes an RPC call for every template rendered providing support for horizontal scaling including parameter based routing.
- Optional built-in support for Apex Debugger to gather debugging information on templates rendered.
Install via Composer with:
composer require apex/syrus
- Designers
- Developers
Get Syrus up and running with the default web site by running the following command within the ~/public/ directory:
php -S 127.0.0.1:8180
The default site including tag examples will now be available at http://127.0.0.1:8180/. Alternatively, if you have docker-compose installed you may achieve the same by running the following command:
sudo docker-compose up -d
use Apex\Syrus\Syrus;
// Start
$syrus = new Syrus();
// Assign some variables
$syrus->assign('name', 'value');
// Assign array
$location = [
'city' => 'Toronto',
'province' => 'Ontario',
'country' => 'Canada'
];
$syrus->assign('loc', $location);
// Add foreach blocks
$syrus->addBlock('users', ['username' => 'jsmith', 'email' => 'jsmith@domain.com']);
$syrus->addBlock('users', ['username' => 'mike', 'email' => 'mike@domain.com']);
// ADd error callout
$this->addCallout('Uh oh, there was a problem.', 'error');
// Render template
echo $syrus->render('contact.html');
// Or, use auto-routing and render template based on URI being viewed.
echo $syrus->render();
If you have any questions, issues or feedback for Syrus, please feel free to drop a note on the ApexPl Reddit sub for a prompt and helpful response.
Loads of good things coming in the near future including new quality open source packages, more advanced articles / tutorials that go over down to earth useful topics, et al. Stay informed by joining the mailing list on our web site, or follow along on Twitter at @mdizak1.