Giter Club home page Giter Club logo

php-yaf-twig's Introduction

\Suin\Yaf\Twig

Twig extension for Yet Another Framework.

Installation

You can install via Composer.

At first create composer.json file:

{
	"require": {
		"suin/php-yaf-twig": ">=1.0"
	}
}

Run composer to install.

$ composer install

Finally, include vendor/autoload.php at index.php

require_once 'vendor/autoload.php';

Add to Bootstrap.php:

<?php

use \Suin\Yaf\Twig\Twig;

class Bootstrap extends Yaf_Bootstrap_Abstract
{

	/**
	 * @param Yaf_Dispatcher $dispatcher
	 */
	protected function _initTwig(Yaf_Dispatcher $dispatcher)
	{
		$config = Yaf_Application::app()->getConfig()
		$dispatcher->setView(new Twig(APP_PATH.'views', $config->twig->toArray()));
	}
}

Add to application.ini:

[product]

;app
application.view.ext = twig

;twig
twig.cache = APP_PATH "../cache"

[devel : product]

;twig
twig.debug = true

License

MIT license

php-yaf-twig's People

Contributors

suin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-yaf-twig's Issues

关于twig显示多级目录的问题

你好,我按照你例子配置,在yaf中接入twig。但是遇到一个问题,不知道你遇到过没有。 具体问题如下: 假设indexController 中的indexAction,默认显示的视图为views/index/index.html, 但是如果在indexAction中使用$this->display('default/index/index.html'),增加一层目录,用于准备多套视图模板,这个时候就是提示错误信息:Twig_Error_Loader: Unable to find template "index/index.html" (looked into: /Users/niefajun/www/xhy/xinghe_front/m/application/views). 是不是只能支持一级目录,不支持两级目录?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.