定制 ytake/laravel-smarty 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ytake/laravel-smarty

Composer 安装命令:

composer require ytake/laravel-smarty

包简介

Smarty template engine for Laravel and Lumen

README 文档

README

Smarty Template Engine for Laravel
(Support for Laravel5.x - Laravel8.x and Lumen)

Build Status Coverage Status Scrutinizer Code Quality

License Latest Version Total Downloads

Installation For Laravel

Require this package with Composer

$ composer require ytake/laravel-smarty

or composer.json

"require": {
  "ytake/laravel-smarty": "^6.0"
},

Supported Auto-Discovery(^Laravel5.5)

add Laravel.Smarty Service Providers

your config/app.php

'providers' => [
    // add smarty extension
    Ytake\LaravelSmarty\SmartyServiceProvider::class, 
    // add artisan commands  
    Ytake\LaravelSmarty\SmartyConsoleServiceProvider::class, 
]

Installation For Lumen

Require this package with Composer

$ composer require ytake/laravel-smarty

or composer.json

"require": {
  "ytake/laravel-smarty": "~2.0"
},

register Laravel.Smarty Service Providers

your bootstrap/app.php

$app->configure('ytake-laravel-smarty');
$app->register(Ytake\LaravelSmarty\SmartyServiceProvider::class);
$app->register(Ytake\LaravelSmarty\SmartyConsoleServiceProvider::class);

Configuration

publish configuration file (for Laravel5)

$ php artisan vendor:publish

publish to config directory

Of Course, Blade Template can also be used to Render Engine.

configuration file (for Lumen)

Copy the vendor/ytake/laravel-smarty/src/config/ytake-laravel-smarty.php file to your local config directory

config for Production

edit config/ytake-laravel-smarty.php

    // enabled smarty template cache
    'caching' => true, // default false
    
    // disabled smarty template compile
    'force_compile' => false, // default true(for develop)

Or

add .env file

SMARTY_CACHE=true
SMARTY_COMPILE=false

edit config/ytake-laravel-smarty.php

    'caching' => env('SMARTY_CACHING', false),
   
    'force_compile' => env('SMARTY_FORCE_COMPILE', true),

and more..!

Basic

easily use all the methods of Smarty

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

View Composer, and View Share

$this->app['view']->composer('index', function (View $view) {
    $view->with('message', 'enable smarty');
});
$this->app['view']->share('title', 'laravel-smarty');
Hello Laravel.Smarty

{$title}

{$message}

Artisan

smarty's cache clear, remove compile class from Artisan(cli)

Template 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 file

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

Template Compiler

$ 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)

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

example

registerFilter in ServiceProvider
registerFilter in Controller
layout.sample
layout.extends.sample

ytake/laravel-smarty 适用场景与选型建议

ytake/laravel-smarty 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 409.16k 次下载、GitHub Stars 达 85, 最近一次更新时间为 2014 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cache」 「template」 「smarty」 「view」 「laravel」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ytake/laravel-smarty 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ytake/laravel-smarty 我们能提供哪些服务?
定制开发 / 二次开发

基于 ytake/laravel-smarty 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 409.16k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 87
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 85
  • Watchers: 7
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-19