Use Laravel Blade template in CodeIgniter based projects
Usage:
-
enable composer autoload in
/application/config/config.php
:$config['composer_autoload'] = TRUE;
-
copy following files:
/application/composer.json
/application/config/blade.php
/application/classes/BladeViewFactory.php
/application/classes/BladeConfigurationInterface.php
/application/classes/CodeIgniterBladeConfiguration.php
/application/helpers/blade_helper.php
-
use in a controller:
echo blade('home.index', [ 'title' => 'Home', ])->render();
For PHP projects using frameworks other than CodeIgniter (and Laravel of course) or no frameworks at all:
- Create class that implements
BladeConfigurationInterface
, for example,MyBladeConfiguration
. - Pass object of
MyBladeConfiguration
toBladeViewFactory
. Seeblade_helper.php
.