PHPackages                             purplebabar/twiger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. purplebabar/twiger

ActiveProject[Framework](/categories/framework)

purplebabar/twiger
==================

A lightweight framework for intwigation

1.0.11(11y ago)029MITPHPPHP &gt;=5.3.0

Since Mar 8Pushed 9y ago1 watchersCompare

[ Source](https://github.com/PurpleBabar/twiger)[ Packagist](https://packagist.org/packages/purplebabar/twiger)[ RSS](/packages/purplebabar-twiger/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (4)Versions (12)Used By (0)

Twiger
======

[](#twiger)

A dead simple framework for intwigation

Twiger is a standalone implementation of twig to allow you to integrate your website and make it 100% ready to import in symfony.

Install
-------

[](#install)

To install Twiger just open a terminal and install via composer with : *php composer create-project purplebabar/twiger nameOfYourProject*. Your server will have to point in your folder, the app.php file will do the rest ;).

Config
------

[](#config)

In the app/config/config.yml, you can configure the folder where your assets are stored, just fill it with

```
assets: nameOfYourFolder
```

Functions
---------

[](#functions)

Two functions are added to the dafualts functions of twig:

### assets(path)

[](#assetspath)

```
The assets function return the path to the assets folder, just add the end of the path. (ex.: yourassets folder is named *assets*, the functino will return you */assets/*

```

### path(routeName, args)

[](#pathroutename-args)

```
The path function return the patter of the route filled with the args you gae in args.

```

Templates
---------

[](#templates)

Your templates must be located in the *src/templates* directory

Routing
-------

[](#routing)

You have different choice regarding the routing. You can either define a controller or a template for direct rendering.

### template

[](#template)

```
second:
  pattern: /foo
  template: bar
```

This syntax will render automatically the bar.html.twig template located in your template directory when /foo will be triggered on your server

### controller

[](#controller)

```
home:
  pattern: /foo/{bar}
  controller: IndexController::foo
```

This syntax will call the foo function of your IndexController, located in the *src/control* of your project.The parameter bar will be transmitted to the function.

Controllers
-----------

[](#controllers)

Your controllers must be defined as follow :

```
