{"id":13746081,"url":"https://github.com/kenjis/codeigniter-ss-twig","last_synced_at":"2025-04-04T12:10:22.837Z","repository":{"id":32462796,"uuid":"36042551","full_name":"kenjis/codeigniter-ss-twig","owner":"kenjis","description":"A Simple and Secure Twig integration for CodeIgniter 3.x and 4.x","archived":false,"fork":false,"pushed_at":"2024-01-18T11:51:13.000Z","size":181,"stargazers_count":167,"open_issues_count":2,"forks_count":46,"subscribers_count":24,"default_branch":"4.x","last_synced_at":"2025-03-28T11:11:44.545Z","etag":null,"topics":["codeigniter","codeigniter3","codeigniter4","hacktoberfest","twig"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kenjis.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-21T23:40:32.000Z","updated_at":"2025-02-25T13:59:55.000Z","dependencies_parsed_at":"2023-11-26T06:29:46.812Z","dependency_job_id":"d406a32d-62ae-4f37-a152-4ef04079257e","html_url":"https://github.com/kenjis/codeigniter-ss-twig","commit_stats":{"total_commits":132,"total_committers":5,"mean_commits":26.4,"dds":"0.045454545454545414","last_synced_commit":"dd85627673560e670bed0d22221c3714bc32c735"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjis%2Fcodeigniter-ss-twig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjis%2Fcodeigniter-ss-twig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjis%2Fcodeigniter-ss-twig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenjis%2Fcodeigniter-ss-twig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenjis","download_url":"https://codeload.github.com/kenjis/codeigniter-ss-twig/tar.gz/refs/heads/4.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174456,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeigniter","codeigniter3","codeigniter4","hacktoberfest","twig"],"created_at":"2024-08-03T06:00:46.110Z","updated_at":"2025-04-04T12:10:22.822Z","avatar_url":"https://github.com/kenjis.png","language":"PHP","readme":"# CodeIgniter Simple and Secure Twig\n\n[![Latest Stable Version](https://poser.pugx.org/kenjis/codeigniter-ss-twig/v/stable)](https://packagist.org/packages/kenjis/codeigniter-ss-twig) [![Total Downloads](https://poser.pugx.org/kenjis/codeigniter-ss-twig/downloads)](https://packagist.org/packages/kenjis/codeigniter-ss-twig) [![Latest Unstable Version](https://poser.pugx.org/kenjis/codeigniter-ss-twig/v/unstable)](https://packagist.org/packages/kenjis/codeigniter-ss-twig) [![License](https://poser.pugx.org/kenjis/codeigniter-ss-twig/license)](https://packagist.org/packages/kenjis/codeigniter-ss-twig)\n\nThis package provides simple Twig integration for [CodeIgniter](https://github.com/codeigniter4/CodeIgniter4) 4.x.\n\nIf you use CodeIgniter 3, check [master](https://github.com/kenjis/codeigniter-ss-twig/tree/master) branch. But Upgrading to CodeIgniter\n4 is strongly recommended.\n\n## Requirements\n\n* PHP 7.4 or later\n* CodeIgniter 4.2.11 or later\n* Twig 3.4.3 or later\n\n## Installation\n\n### With Composer\n\n~~~\n$ cd /path/to/codeigniter/\n$ composer require kenjis/codeigniter-ss-twig\n~~~\n\n## Usage\n\n### Loading Twig Library\n\n~~~php\n$this-\u003etwig = new \\Kenjis\\CI4Twig\\Twig();\n~~~\n\nYou can override the default configuration:\n\n~~~php\n$config = [\n    'paths' =\u003e ['/path/to/twig/templates', VIEWPATH],\n    'cache' =\u003e '/path/to/twig/cache',\n];\n$this-\u003etwig = new \\Kenjis\\CI4Twig\\Twig($config);\n~~~\n\n### Rendering Templates\n\nRender Twig template and output to browser:\n\n~~~php\n$this-\u003etwig-\u003edisplay('welcome', $data);\n~~~\n\nThe above code renders `Views/welcome.twig`.\n\nRender Twig template:\n\n~~~php\n$output = $this-\u003etwig-\u003erender('welcome', $data);\n~~~\n\nThe above code renders `Views/welcome.twig`.\n\n### Adding a Global Variable\n\n~~~php\n$this-\u003etwig-\u003eaddGlobal('sitename', 'My Awesome Site');\n~~~\n\n### Getting Twig\\Environment Instance\n\n~~~php\n$twig = $this-\u003etwig-\u003egetTwig();\n~~~\n\n### Supported CodeIgniter Helpers\n\n* `base_url()`\n* `site_url()`\n* `anchor()`\n* `form_open()`\n* `form_close()`\n* `form_error()`\n* `form_hidden()`\n* `set_value()`\n* `csrf_field()`\n* `validation_list_errors()`\n\nSome helpers are added the functionality of auto-escaping for security.\n\n\u003e **Warning**\n\u003e `validation_list_errors()` shows Validation Errors by `Services::validation()-\u003elistErrors()`,\n\u003e and if you use user input for Validation Error messages, attackers may do XSS.\n\u003e In such a case, validate user input and escape it by yourself.\n\n### Adding Your Functions \u0026 Filters\n\nYou can add your functions and filters with configuration:\n\n~~~php\n$config = [\n    'functions'      =\u003e ['my_helper'],\n    'functions_safe' =\u003e ['my_safe_helper'],\n    'filters'        =\u003e ['my_filter'],\n];\n$this-\u003etwig = new \\Kenjis\\CI4Twig\\Twig($config);\n~~~\n\nIf your function explicitly outputs HTML code, you want the raw output to be printed.\nIn such a case, use `functions_safe`, and **you have to make sure the output of\nthe function is XSS free**.\n\n### References\n\n#### Documentation\n\n* https://twig.symfony.com/doc/3.x/\n\n#### Samples\n\n* https://github.com/kenjis/ci4-twig-sample\n* https://github.com/kenjis/ci4-tettei-apps (Japanese)\n\n## How to Run Tests\n\n~~~\n$ cd codeigniter-ss-twig\n$ composer install\n$ vendor/bin/phpunit\n~~~\n\n## Related Projects for CodeIgniter 4.x\n\n### Libraries\n\n- [CodeIgniter 3 to 4 Upgrade Helper](https://github.com/kenjis/ci3-to-4-upgrade-helper)\n- [CodeIgniter3-like Captcha](https://github.com/kenjis/ci3-like-captcha)\n- [PHPUnit Helper](https://github.com/kenjis/phpunit-helper)\n- [CodeIgniter4 Attribute Routes](https://github.com/kenjis/ci4-attribute-routes)\n- [CodeIgniter Simple and Secure Twig](https://github.com/kenjis/codeigniter-ss-twig)\n- [CodeIgniter4 Viewi Demo](https://github.com/kenjis/ci4-viewi-demo)\n\n### Tutorials\n\n- [CodeIgniter 4 News Tutorial](https://github.com/kenjis/ci4-news)\n- [CodeIgniter 4 Validation Tutorial](https://github.com/kenjis/ci4-validation-tutorial)\n- [CodeIgniter4 Code Modules Test](https://github.com/kenjis/ci4-modules-test)\n- [CodeIgniter 4 File Upload](https://github.com/kenjis/ci4-file-upload)\n- [CodeIgniter 4 QueryBuilder Batch Sample](https://github.com/kenjis/ci4-qb-batch-sample)\n\n### Building Development Environment\n\n- [CodeIgniter4 Application Template](https://github.com/kenjis/ci4-app-template)\n- [CodeIgniter4 Composer Installer](https://github.com/kenjis/ci4-composer-installer)\n- [docker-codeigniter-apache](https://github.com/kenjis/docker-codeigniter-apache)\n","funding_links":[],"categories":["Templates"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenjis%2Fcodeigniter-ss-twig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenjis%2Fcodeigniter-ss-twig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenjis%2Fcodeigniter-ss-twig/lists"}