Skip to content

ytake/Laravel.Smarty

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel.Smarty

smarty template engine for laravel

Build Status Coverage Status Dependency Status Code Climate

License Latest Version Total Downloads

HHVM Status
Latest Unstable Version SensioLabsInsight

##Basic laravel4でsmartyを使用できます。
bladeの構文をそのまま使用することができ、
それに加え、View Facadeを通じてsmartyのmethodはすべて利用可能です。
easily use all the methods of smarty

// laravel blade template render
\View::make('template', ['hello']);
// use smarty method
\View::assign('word', 'hello');  
\View::clearAllAssign(); // smarty method

###example registerFilter in ServiceProvider
registerFilter in Controller
layout.sample
layout.extends.sample ##Install

###for Laravel4.2.*

"require": {
  "ytake/laravel-smarty": "1.2.*"
},

###for Laravel4.1.*

"require": {
  "ytake/laravel-smarty": "1.1.*"
},

###for Laravel5(develop)

"require": {
  "ytake/laravel-smarty": "dev-develop-5"
},

##Artisan キャッシュクリア、コンパイルファイルの削除がコマンドラインから行えます。
smarty's cacheclear, remove compile class from Artisan(cli) ###cache clear

$ php artisan ytake:smarty-clear-cache
Options description
--file (-f) specify file
--time (-t) clear all of the files that are specified duration time
--cache_id (-cache) specified cache_id groups

###remove compile class

$ php artisan ytake:smarty-clear-compiled
Options description
--file (-f) specify file
--compile_id (-compile) specified compile_id

###compile

$ php artisan ytake:smarty-optimize
Options description
--extension (-e) specified smarty file extension(default: .tpl)
--force compiles template files found in views directory

Template Caching

choose file, memcached, Redis
(default file cache driver)

テンプレートキャッシュドライバにファイルキャッシュ、memcached, Redisが選択できます
デフォルトは通常のファイルキャッシュになっています

// 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,
    ],
],

Usage

install後、 app/config配下のapp.phpのproviders配列に以下のnamespaceを追加してください。
add providers

'providers' => [
    'Ytake\LaravelSmarty\SmartyServiceProvider'
]

configファイルをpublishします。
publish configure

$ php artisan config:publish ytake/laravel-smarty

app/config/packages配下に追加されます。
publish to app/config/packages

views配下にsmartyファイルがあればそれをテンプレートと使用し、
なければ通常通りbladeテンプレートかphpファイルを使用します。

smartyテンプレート内にも*{{app_path()}}*等のヘルパーそのまま使用できます。
その場合、delimiterをbladeと同じものを指定しない様にしてください。

About

smarty template engine for laravel

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 12