nitronet / fwk-twig
Installs: 36
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/nitronet/fwk-twig
This package is not auto-updated.
Last update: 2025-09-27 20:42:01 UTC
README
Brings Twig template engine support for Fwk\Core Applications.
Installation
1: Install the sources
Via Composer:
{
"require": {
"nitronet/fwk-twig": "dev-master",
}
}
If you don't use Composer, you can still download this repository and add it
to your include_path
PSR-0 compatible
2: Defines Twig as a Service
Define a Twig_Environment
instance in your Di Container, and configure it the way you want:
<!-- Twig_Environment Configuration --> <array-definition name="twig.config"> <param key="debug">true</param> </array-definition> <!-- Twig_Loader definition --> <class-definition name="twig.loader" class="\Twig_Loader_Filesystem" shared="true"> <!-- :packageDir = directory of this .xml file --> <argument>:packageDir/path/to/templates</argument> </class-definition> <!-- Twig_Environment definition --> <class-definition name="twig" class="\Twig_Environment" shared="true"> <argument>@twig.loader</argument> <argument>@twig.config</argument> </class-definition>
3: Register Twig ResultType
Registers a new ResultType in fwk.xml:
<result-type name="twig" class="FwkTwig\TwigResultType"> <param name="twigService">twig</param> </result-type>
4: Enjoy!
Use the ResultType where you want:
<action name="Home" shortcut="MyApp\Controllers\Home:show"> <result name="success" type="twig"> <param name="file">home.twig</param> </result> </action>
Contributions / Community
- Issues on Github: https://github.com/nitronet/fwk-twig/issues
- Follow Fwk on Twitter: @phpfwk