|
| 1 | +# Codeigniter-Twig |
| 2 | +### [Dimas Rullyan Danu](https://id.linkedin.com/in/dimasdanz) (dimasdanz@gmail.com) |
| 3 | + |
| 4 | +Simple Twig Templating Engine implementation on Codeigniter 3.0 via Composer |
| 5 | + |
| 6 | +## Installation |
| 7 | +1. **Add & Install Twig via Composer** |
| 8 | + Yes, you can use composer on Codeigniter 3.0 out of the box. Just open composer.json and add |
| 9 | + |
| 10 | + ``` |
| 11 | + "config": { |
| 12 | + "vendor-dir": "application/vendor" |
| 13 | + }, |
| 14 | + "require": { |
| 15 | + "twig/twig": "~1.0" |
| 16 | + } |
| 17 | + ``` |
| 18 | + and run composer update (or install if you haven't already) |
| 19 | + *application/vendor is Codeigniter default location for vendor |
| 20 | + |
| 21 | +1. **Enable Codeigniter composer_autoload** |
| 22 | + Open config.php on application/config (or wherever you have it set) and set |
| 23 | + ``` |
| 24 | + $config['composer_autoload`] = TRUE; |
| 25 | + ``` |
| 26 | + |
| 27 | +1. **Copy Files & Directories** |
| 28 | + Copy the contents of the application folder to your own application folder. |
| 29 | + If you already configured autoload.php, you might don't want to copy it directly as it will overwrite your configuration. |
| 30 | + Just add Twig on libraries autoload and twig on config autoload. |
| 31 | + ``` |
| 32 | + $autoload['libraries'] = array('Twig'); |
| 33 | + $autoload['config'] = array('twig'); |
| 34 | + ``` |
| 35 | + And also if you have MY_Loader (or with any prefixes), you might just wanna modify it. |
| 36 | + |
| 37 | +1. **Check Config Settings** |
| 38 | + The default settings work out of the box. |
| 39 | + But if you wanna change it, check the twig.php config file |
| 40 | + |
| 41 | +1. **Add Write Permissions to Cache Directory** |
| 42 | + Make sure application/cache has permission to write if you enable cache (e.g CHMOD 777). |
| 43 | + |
| 44 | +## Usage |
| 45 | +Loading the view still the same as the original Codeigniter **load->view('view_file', $data)** |
| 46 | +So caching, output modification, etc will still works |
| 47 | +Now you can use every Twig syntax on your view files |
| 48 | + |
| 49 | +## What is Twig |
| 50 | +[Twig](http://twig.sensiolabs.org/) is PHP Template Engine. Or The flexible, fast, and secure template engine for PHP (as how their website state it) |
| 51 | +Template Engine provides a cleaner syntax and additional features for your view files |
| 52 | +For information about Twig and how to use it, please visit [Twig's Documentation](http://twig.sensiolabs.org/documentation) |
| 53 | + |
| 54 | +## License |
| 55 | + |
| 56 | +#### DON'T BE A DICK PUBLIC LICENSE |
| 57 | + |
| 58 | +> Version 1, December 2009 |
| 59 | +
|
| 60 | +> Copyright (C) 2009 Philip Sturgeon <me@philsturgeon.uk> |
| 61 | + |
| 62 | + Everyone is permitted to copy and distribute verbatim or modified |
| 63 | + copies of this license document, and changing it is allowed as long |
| 64 | + as the name is changed. |
| 65 | + |
| 66 | +> DON'T BE A DICK PUBLIC LICENSE |
| 67 | +> TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
| 68 | +
|
| 69 | + 1. Do whatever you like with the original work, just don't be a dick. |
| 70 | + |
| 71 | + Being a dick includes - but is not limited to - the following instances: |
| 72 | + |
| 73 | + 1a. Outright copyright infringement - Don't just copy this and change the name. |
| 74 | + 1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick. |
| 75 | + 1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick. |
| 76 | + |
| 77 | + 2. If you become rich through modifications, related works/services, or supporting the original work, |
| 78 | + share the love. Only a dick would make loads off this work and not buy the original work's |
| 79 | + creator(s) a pint. |
| 80 | + |
| 81 | + 3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes |
| 82 | + you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back. |
| 83 | + |
| 84 | +## Change Log |
| 85 | + |
| 86 | +#### 1.0.0 - May 23, 2015 |
| 87 | +Initial release. |
| 88 | + |
| 89 | +## Credit |
| 90 | + 1. [Codeigniter 3.0.0] (http://www.codeigniter.com) |
| 91 | + 1. [Twig PHP Template Engine] (http://twig.sensiolabs.org/) |
| 92 | + 1. [Codeigniter_Smarty] (https://github.com/cryode/CodeIgniter_Smarty) |
| 93 | + 1. [Codeigniter-Twiggy] (https://github.com/edmundask/codeigniter-twiggy) |
| 94 | + 1. If you think your name should be here, feel free to contact me |
| 95 | + |
| 96 | +###Contact: |
| 97 | + + [Facebook](http://www.facebook.com/Dimasdanz) |
| 98 | + + [Twitter](http://www.twitter.com/Dimasdanz) |
| 99 | + + [LinkedIn](https://id.linkedin.com/in/dimasdanz) |
| 100 | + + dimasdanz@gmail.com |
0 commit comments