定制 scorninpc/slim-smarty-view 二次开发

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

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

scorninpc/slim-smarty-view

Composer 安装命令:

composer require scorninpc/slim-smarty-view

包简介

Slim Framework 4 view helper built on top of the Smarty templating component

README 文档

README

Latest Stable Version Total Downloads License

This is a Slim Framework 4 view helper built on top of the Smarty templating component. You can use this component to create and render templates in your Slim Framework 4 application.

How to install

Via Composer

$ composer require scorninpc/slim-smarty-view "2.*"

Example

<?php

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

require __DIR__ . '/vendor/autoload.php';


// Create Container
$container = new \DI\Container();
AppFactory::setContainer($container);

// Create the app
$app = AppFactory::create();

// Set view in Container
$container->set("view", function($container) {

  // Create smarty view
  $view = new \Slim\Views\Smarty(
    [
      'template_dir' => [__DIR__ . "/templates"],   // Where to put .tpl files
      'compile_dir' =>  __DIR__ . "/templates_c",   // Where to save compiled

      'cache_dir' =>  __DIR__ . "/templates_c",   // Where to cache
      'caching' => FALSE,               // Enable usa of cache
      'cache_lifetime' => 4600,           // Time for cache

      'force_compile' => TRUE,            // Force to compile .tpl all the time (compile .tpl every time . this is slow for production)
      'debugging' => FALSE,             // Enable debug console
      'compile_check' => TRUE,            // Enable check if need compile (this will check timestamp of file and compile again. set to false for performance)
    ]
  );

  return $view;
});

// Route
$app->get('/', function (Request $request, Response $response, $args) {

  return $this->get('view')->render($response, 'index.tpl', [
    'variable' => "Hello!",
  ]);
  
});

// Run
$app->run();

Credits

This project is only a fork to add examples and the package on packagist to work with composer, all credits of this nice rework are from Matheus Marques

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固