doujiu8479 2014-07-19 17:26
浏览 19

TWIG模板系统基本安装简单吗?

trying to use TWIG templates system on my php project , its my first time i am using this templates system , when i went to installation page i found to many ways

also is it require apache extension to work ? becouse i found this in the bottom of the page

extension=twig.so #For Unix systems
extension=php_twig.dll #For Windows systems

i am developing my script on my Mac , i could't find example for Mac

if someone using this templates system can you advice me how to basically install this script ?

many thanks

  • 写回答

1条回答 默认 最新

  • doujingya1166 2014-07-19 17:59
    关注

    i found it

    1. copy the folder "lib" to your project

    and this is example code

    require_once("/path here/lib/Twig/Autoloader.php" );
    
      Twig_Autoloader::register();
    
      $loader = new Twig_Loader_Filesystem( DIR . '/templates/');
    $twig = new Twig_Environment($loader, array(
        'cache' => DIR . '/cache',
    ));
    
    echo $twig->render('home.tpl', array('name' => 'Fabien'));
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度