apex / syrus
Light-weight, extensible template engine.
Installs: 888
Dependents: 4
Suggesters: 1
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=8.1
- apex/container: ^2.0
- brick/phonenumber: ^0.4
- league/uri: ^6.0 | ^7.3
- michelf/php-markdown: ^2.0
- psr/cache: ^1.0 | ^2.0
- symfony/string: ^6.0 | ^7.0
- symfony/yaml: ^6.0 | ^7.0
Requires (Dev)
- apex/signer: ^2.0
- phpunit/phpunit: ^9.5
Suggests
- apex/debugger: >=0.1.4
- symfony/cache: ^6.2
This package is auto-updated.
Last update: 2024-11-11 03:59:48 UTC
README
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.
Installation
Install via Composer with:
composer require apex/syrus
Table of Contents
- Designers
- Developers
Local Server
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
Basic Usage
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();
Support
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.
Follow Apex
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.