moazamin6 / creative-blade
Standalone laravel blade for all existing and new php projects
Requires
- php: ^7.3|^8.0
- ext-json: *
- illuminate/collections: ^8.0
- illuminate/container: ^8.0
- illuminate/contracts: ^8.0
- illuminate/events: ^8.0
- illuminate/filesystem: ^8.0
- illuminate/macroable: ^8.0
- illuminate/support: ^8.0
This package is auto-updated.
Last update: 2024-11-23 16:21:25 UTC
README
Full compatible to every php application standalone laravel's blade modify on illuminate/view v6.10.0
Installation
Install using composer:
composer require moazamin6/creative-blade
Usage
Create a Blade instance by passing it the folder(s) where your view files are located, and a cache folder. Render a template by calling the make
method. More information about the Blade templating engine can be found on https://laravel.com/docs/7.x/blade.
require 'vendor/autoload.php'; use CreativeBlade\CreativeBlade; $views = __DIR__ . '/views'; $cache = __DIR__ . '/cache'; $blade = new CreativeBlade($views, $cache); echo $blade->view()->make('demo', ['message' => 'This is Creative Blade']);
In every other standalone blade template package there is a problem that you can not use $this keyword to access your native application features for example if you want to implement blade template in your existing codeigniter application in views files you access your sessions like
$this->session
if you convert your views to blade then your application will crash in this scenario so I modify actual illuminate/view
package of laravel to solve this problem and I also use existing standalone package coolpraz/php-blade
so here you can send you data object that you want to access in view like this
I will use codeigniter default instance
$ci = &get_instance(); $blade = new CreativeBlade($views, $cache,$ci);
Now you can easily create a directive by calling the compiler()
function
$blade->compiler()->directive('datetime', function ($expression) { return "<?php echo with({$expression})->format('F d, Y g:i a'); ?>"; }); {{-- In your Blade Template --}} <?php $dateObj = new DateTime('2017-01-01 23:59:59') ?> @datetime($dateObj)
The Blade instances passes all methods to the internal view factory. So you can use all blade features as described in the Blade documentation, please visit site for more information.
Integrations
You can use PHP Blade with any framework, vanilla php script or can be use developing any plugins for CMS.