Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Twig extension not recognized
  • Hello community,

    i have updated fuelphp to 1.9/dev

    dont know why but fuelphp does not recognize my twig extention :(

    Custom Twig Functions are not available on my twig views




    This is my parse config

    'View_Twig' => array(
    'include' => APPPATH.'vendor'.DS.'twig'.DS.'lib'.DS.'Twig'.DS.'Autoloader.php',
    'auto_encode' => true,
    'views_paths' => array(APPPATH.'views'),
    'delimiters' => array(
    'tag_block' => array('left' => '{%', 'right' => '%}'),
    'tag_comment' => array('left' => '{#', 'right' => '#}'),
    'tag_variable' => array('left' => '{{', 'right' => '}}'),
    ),
    'environment' => array(
    'debug' => false,
    'charset' => 'utf-8',
    'base_template_class' => 'Twig_Template',
    'cache' => APPPATH.'cache'.DS.'twig'.DS,
    'auto_reload' => true,
    'strict_variables' => false,
    'autoescape' => true,
    'optimizations' => -1,
    ),
    'extensions' => array(
    'Twig_Fuel_Extension',
    ),
    ),


    Any Idea?

  • So loading a "viewname.twig" works, the twig syntax in the view works (i.e. twig itself works), but you don't have the extensions available?
  • Yes Twig works, only the extension does not work. I use this configuration since years, never seen this issue on other projects.

    Very funny, using fuelphp 1.9/dev on another project with twigt and the twig extention on this projects works 
  • That is indeed weird. I have no explanation for it, you might have to do some debugging.
  • Hey, i have twig lib on my app/vendor folder? is this right?

    i see on console that the extention file is not loaded by twig.

    any changes on autoload?
  • Nope. 

    Twig should be installed by composer (it is defined in recommends in composer.json) and is added to fuel/vendor by composer. If you have something in app/vendor it is manually installed.

    It could also be that because of this, you're using an old Twig version. Fuel needs Twig 2.x.

    The extension class is loaded by the Parser packages' View extension for twig: https://github.com/fuel/parser/blob/1.9/develop/classes/view/twig.php#L106

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion