PHP code example of ytake / laravel-smarty
1. Go to this page and download the library: Download ytake/laravel-smarty library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ytake / laravel-smarty example snippets
'providers' => [
// add smarty extension
Ytake\LaravelSmarty\SmartyServiceProvider::class,
// add artisan commands
Ytake\LaravelSmarty\SmartyConsoleServiceProvider::class,
]
$app->configure('ytake-laravel-smarty');
$app->register(Ytake\LaravelSmarty\SmartyServiceProvider::class);
$app->register(Ytake\LaravelSmarty\SmartyConsoleServiceProvider::class);
// enabled smarty template cache
'caching' => true, // default false
// disabled smarty template compile
'force_compile' => false, // default true(for develop)
'caching' => env('SMARTY_CACHING', false),
'force_compile' => env('SMARTY_FORCE_COMPILE', true),
// laravel5 view render
view("template.name");
// Laravel blade template render(use Facades)
\View::make('template', ['hello']);
// use Smarty method
\View::assign('word', 'hello');
\View::clearAllAssign(); // smarty method
$this->app['view']->composer('index', function (View $view) {
$view->with('message', 'enable smarty');
});
$this->app['view']->share('title', 'laravel-smarty');
// smarty cache driver "file", "memcached", "redis"
'cache_driver' => 'file',
// memcached servers
'memcached' => [
[
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 100
],
],
// redis configure
'redis' => [
[
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
],
],
bash
$ php artisan vendor:publish
bash
$ php artisan ytake:smarty-clear-cache
bash
$ php artisan ytake:smarty-clear-compiled
bash
$ php artisan ytake:smarty-optimize