Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
FuelPHP 1.61 and Smarty 3.1.14
  • Are there any tutorial or guide for integrating Smarty to FuelPHP?  and i want to use extension .tpl not .smarty  , and is it neccesary to keep Twig? I just want to use FuelPHP and Smarty, Thanks in advanced all!

    Greetings,


  • HarroHarro
    Accepted Answer
    Enable the parser package in the always_load section of your config. Then copy the parser.php config file to app/config. Then change the extension definitions to:

        'extensions' => array(
            'dwoo'      => array('class' => 'View_Dwoo', 'extension' => 'dwoo'),
            'smarty'    => array('class' => 'View_Smarty', 'extension' => 'tpl'),
        ),

    and you're in Business.

    You can install Smarty through composer.
  • How Can I install it via the Composer? I'm new to this, Thanks again for your help!
  • HarroHarro
    Accepted Answer
    See https://packagist.org/packages/smarty/smarty

    Select the one you want, add the "require" to the composer.json file in the Fuel root, and run "php composer.phar update" to install the package.
  • I added and it gives me errors
  • [Seld\JsonLint\ParsingException]
    "composer.json" does not contain valid JSON
    Parse error on line 21:
    ...php/upload": "2.0" "smarty/smarty": "v3
    ----------------------
    Expected one of: 'EOF', '}', ':', ',', ']'
  • ooopss sorry my bad i missed a comma
  • root@ubuntu:/home/csanchez/Downloads/Sites/Fuel# php composer.phar update
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing smarty/smarty (v3.1.14)
        Checking out /tags/v3.1.14/@4752


                                                              
      [RuntimeException]                                      
      Package could not be downloaded, sh: 1: svn: not found  
                                                              
                                                              


    update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]


    root@ubuntu:/home/csanchez/Downloads/Sites/Fuel# 

  • You're trying to install the 'dev' version, which composer wants to install directly from the source repository, which from the looks of it is an svn repository. And you don't have svn installed.
  • I´m sorry but i dont get it.
    "Enable the parser package in the always_load section of your config" <- What config?<br />
    A step by step instruction would be in place here or a link to one. I haven´t found one during my search
  • Perhaps you should check out the documentation. Select "General, Configuration" from the menu, and read how to configure the framework. You'll see "always_load" already mentioned in the 4th paragraph.

    Add the parser package to it, copy parser.php from fuel/packages/parser/config to app/config, and change if needed. You'll probably want to use the ".tpl" extension for smarty templates, instead of ".smarty". You'll have to change the twig extension to something else first, the extension to parser mapping should be unique.

    One the parser is configured, and the Smarty composer package is installed, you can just do

    View::forge('my/smarty/template.tpl');

    and load Smarty templates instead of PHP templates.

Howdy, Stranger!

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

In this Discussion