{"id":18929500,"url":"https://github.com/thecodingmachine/twig-universal-module","last_synced_at":"2026-02-20T19:32:09.702Z","repository":{"id":57067886,"uuid":"59120730","full_name":"thecodingmachine/twig-universal-module","owner":"thecodingmachine","description":"Cross-framework module for Twig","archived":false,"fork":false,"pushed_at":"2018-08-19T19:50:03.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"1.1","last_synced_at":"2025-10-25T01:27:36.300Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-18T14:00:49.000Z","updated_at":"2018-08-19T19:50:05.000Z","dependencies_parsed_at":"2022-08-24T14:54:08.445Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/twig-universal-module","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/twig-universal-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Ftwig-universal-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Ftwig-universal-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Ftwig-universal-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Ftwig-universal-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/twig-universal-module/tar.gz/refs/heads/1.1","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Ftwig-universal-module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29661595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T16:33:43.953Z","status":"ssl_error","status_checked_at":"2026-02-20T16:33:43.598Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-08T11:33:00.956Z","updated_at":"2026-02-20T19:32:09.673Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/thecodingmachine/twig-universal-module.svg?branch=1.0)](https://travis-ci.org/thecodingmachine/twig-universal-module)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/twig-universal-module/badge.svg?branch=1.0\u0026service=github)](https://coveralls.io/github/thecodingmachine/twig-universal-module?branch=1.0)\n\n\n# Twig universal module\n\nThis package integrates Twig in any [container-interop/service-provider](https://github.com/container-interop/service-provider) compatible framework/container.\n\n## Installation\n\n```\ncomposer require thecodingmachine/twig-universal-module\n```\n\nOnce installed, you need to register the [`TheCodingMachine\\TwigServiceProvider`](src/TwigServiceProvider.php) into your container.\n\nIf your container supports thecodingmachine/discovery integration, you have nothing to do. Otherwise, refer to your framework or container's documentation to learn how to register *service providers*.\n\n## Introduction\n\nThis service provider is meant to create a base `Twig_Environment` instance.\n\nOut of the box, the instance should be usable with sensible defaults. We tried to keep the defaults usable for most of the developer, while still providing caching for good performances.\nIf you are looking for the best performances, you will need to tweak the settings.\n\n### Usage\n\n```php\n$twig = $container-\u003eget('Twig_Environement');\necho $twig-\u003erender('views/my.twig', [ 'foo' =\u003e 'bar' ]);\n```\n\n### Default values\n\nBy default:\n\n- Caching is enabled, in a directory under the temporary system directory. In production, if you are running a multi-user environment, you might want to change that to a directory only readable by you.\n- `autoreload = true`: You can safely modify any Twig file without needing to purge the cache. In production, if you are looking for best performance, put this to `false`.\n- Twig files will be loaded from the root of your project (the directory where the `composer.json` file is). You can change that by overloading the `Twig_LoaderInterface` entry or the `Twig_Loader_Filesystem` entry.\n- By default, `debug = true` unless your provide a value in the `DEBUG` entry of your container.\n\n## Expected values / services\n\n**Important**: when this service provider looks for a service, it will first look for the service prefixed with the package name, then for the service directly.\nSo if this documentation states that the `DEBUG` entry is used, the service provider will first look into `thecodingmachine.twig-universal-module.DEBUG` and then into `DEBUG`.\nThis allows you to keep your container clean (with only one `DEBUG` entry), and in case there are several service providers using that `DEBUG` entry and you want to pass different values, you can still edit `thecodingmachine.twig-universal-module.DEBUG` for this service provider only.\n\n\nThis *service provider* expects the following configuration / services to be available:\n\n| Name            | Compulsory | Description                            |\n|-----------------|------------|----------------------------------------|\n| `DEBUG`         | *no*       | The debug mode of Twig |\n\n\n## Provided services\n\nThis *service provider* provides the following services:\n\n| Service name                | Description                          |\n|-----------------------------|--------------------------------------|\n| `Twig_Environment::class`  | The Twig_Environment instance   |\n| `Twig_LoaderInterface::class`  | An alias to the loader chain (by default, the Twig_Environment is using a loader chain)   |\n| `Twig_Loader_Chain::class`  |  Instance of the loader chain.  |\n| `twig_options`  | An array containing options passed to Twig (see default values in previous chapter).  |\n| `twig_loaders`  | An array of loaders. Contains by default a single instance of the `Twig_Loader_Filesystem`.   |\n| `Twig_Loader_Filesystem::class`  |  The default instance of the `Twig_Loader_Filesystem`.  |\n| `twig_directory`  | The base directory storing the Twig files. Defaults to root directory of the project. Used by `Twig_Loader_Filesystem`.   |\n| `twig_cache_directory`  |  Default directory that stores Twig compiled templates. |\n\n## Extended services\n\nThis *service provider* does not extend any service.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Ftwig-universal-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Ftwig-universal-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Ftwig-universal-module/lists"}