-
Notifications
You must be signed in to change notification settings - Fork 120
Home
Jorge Castro edited this page Apr 22, 2020
·
5 revisions
example.php:
include "lib/BladeOne.php"; // you should change it and indicates the correct route.
Use eftec\bladeone;
$views = __DIR__ . '/views'; // it uses the folder /views to read the templates
$cache = __DIR__ . '/cache'; // it uses the folder /cache to compile the result.
$blade = new bladeone\BladeOne($views,$cache,BladeOne::MODE_AUTO);
echo $blade->run("hello",array("variable1"=>"value1")); // /views/hello.blade.php must exist
include "../lib/BladeOne.php";
// The nulls indicates the default folders. By drfault it's /views and /compiles
// \eftec\bladeone\BladeOne::MODE_DEBUG is useful because it indicates the correct file if the template fails to load.
// You must disable it in production.
$blade = new \eftec\bladeone\BladeOne(null,null,\eftec\bladeone\BladeOne::MODE_DEBUG);
echo $blade->run("Test.hello", []); // the template must be in /views/Test/hello.blade.php
require "vendor/autoload.php";
Use eftec\bladeone\BladeOne;
$views = __DIR__ . '/views';
$cache = __DIR__ . '/cache';
$blade = new BladeOne($views,$cache,BladeOne::MODE_AUTO);
echo $blade->run("hello",array("variable1"=>"value1"));
Run the next composer command:
composer require eftec/bladeone
Where $views
is the folder where the views (templates not compiled) will be stored.
$cache
is the folder where the compiled files will be stored.
In this example, the BladeOne opens the template hello. So in the views folder it should exist a file called hello.blade.php
views/hello.blade.php:
<h1>Title</h1>
{{$variable1}}
Copyright Jorge Castro Castillo
- BladeOne Manual
- Template tags (views)
- Custom control
- Methods of the class
- Injecting logic before the view (composer)
- Extending the class
- Using BladeOne with YAF Yet Another Framework
- Differences between Blade and BladeOne
- Comparision with Twig (May-2020)
- Changelog
- Changes between 2.x and 3.0 and TODO
- Code Protection (Sourceguardian and similars)