Skip to content
Jorge Castro edited this page Apr 22, 2020 · 5 revisions

Usage

Without composer's autoload.php

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

Without namespace nor composer

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

With composer's autoload.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}}