There are just two steps needed to install php-lare:
-
Add php-lare to your composer.json:
{ "require": { "lare_team/php_lare": ">=1.0.0", } }
-
Set the current Lare namespace in your View or anywhere before your templates get rendered:
use Lare_Team\Lare\Lare as Lare; ... Lare::set_current_namespace('Current.Lare.Namespace');
This example seems to show a huge overhead, actually only the if-else tags make it that big.
// View:
if (!Lare::matches('Lare')) {
// Do everything you need only for the whole site.
}
if (!Lare::matches('Lare.Home')) {
// Do everything you need to handle the home page.
}
// Head-Template:
if (!Lare::matches('Lare')) {
<html>
<head>
// Scripts and Stylesheets could be loaded here, no need to reload them when changing the page
<script...
<link...
<?php } else { ?>
<lare-head>
<?php }
...
if (!Lare::matches('Lare')) {
</head>
<?php } else { ?>
</lare-head>
<?php }
// Body-Template:
if (!Lare::matches('Lare')) {
<body>
<header>...</header>
<div id="site">
...
<div id="page">
<?php } else { ?>
<lare-body>
<?php }
// Render everything you need in the page container.
if (!Lare::matches('Lare')) { ?>
</div>
...//site content could still be here
<footer></footer>
</div>
</body>
<?php } else { ?>
</lare-body>
<?php } ?>
If this seems to be too complex for you, try twig in combination with twig-lare for templating.
If you are using php-lare, please contact us, and tell us in which projects you are using it. Thank you!
Happy speeding up your php project!
For further information read php-lare on iekadou.com