{"id":15167234,"url":"https://github.com/mrtnzlml/compiler-extension","last_synced_at":"2025-10-01T00:31:14.832Z","repository":{"id":56940685,"uuid":"69755689","full_name":"mrtnzlml-archive/compiler-extension","owner":"mrtnzlml-archive","description":":crown: Enhanced CompilerExtension for Nette Framework","archived":true,"fork":false,"pushed_at":"2017-07-16T08:22:27.000Z","size":65,"stargazers_count":11,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-20T23:37:24.700Z","etag":null,"topics":["dic-extension","neon","nette-framework"],"latest_commit_sha":null,"homepage":"http://zlml.cz/muskulaturni-rozsireni-dic","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/mrtnzlml-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-01T18:23:39.000Z","updated_at":"2023-03-14T01:00:41.000Z","dependencies_parsed_at":"2022-08-21T06:50:23.914Z","dependency_job_id":null,"html_url":"https://github.com/mrtnzlml-archive/compiler-extension","commit_stats":null,"previous_names":["adeira/compiler-extension"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnzlml-archive%2Fcompiler-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnzlml-archive%2Fcompiler-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnzlml-archive%2Fcompiler-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnzlml-archive%2Fcompiler-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrtnzlml-archive","download_url":"https://codeload.github.com/mrtnzlml-archive/compiler-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234796859,"owners_count":18888157,"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":["dic-extension","neon","nette-framework"],"created_at":"2024-09-27T05:42:00.665Z","updated_at":"2025-10-01T00:31:09.528Z","avatar_url":"https://github.com/mrtnzlml-archive.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e At this moment I don't have time, energy and money to maintain this project. But it's a shame so if you depend on this project and you want to become a sponsor or develop it further please don't hesitate to contact me. Otherwise, I am not able to guarantee bright future of this repo... :)\n\n# Enhanced CompilerExtension for Nette Framework\n\n[![Build Status](https://travis-ci.org/adeira/compiler-extension.svg?branch=master)](https://travis-ci.org/adeira/compiler-extension)\n\nIf you have more complicated project structure with a lot of bundles (DIC extensions), it's very common that you have to setup a lot of things and it may be quite difficult. But not with this extension. All you need is to use `Adeira\\ConfigurableExtensionsExtension` instead of default `ExtensionsExtension` like this (probably in `bootstrap.php`):\n\n```php\n$configurator-\u003edefaultExtensions['extensions'] = \\Adeira\\ConfigurableExtensionsExtension::class;\n```\n\nThis new extension will take care of configuration files in your bundles. Next if you want to use custom config for extension, just use `provideConfig` method:\n\n```php\n\u003c?php\n\nnamespace App\\Articles\\DI;\n\nclass ArticlesExtension extends \\Adeira\\CompilerExtension\n{\n\n  public function provideConfig()\n  {\n    return __DIR__ . '/config.neon';\n  }\n\n  public function beforeCompile()\n  {\n    $this-\u003esetMapping(['Articles' =\u003e 'App\\Articles\\*Module\\Presenters\\*Presenter']);\n  }\n\n}\n```\n\nYou don't have to extend `Adeira\\CompilerExtension` but there is useful helper `setMapping()` (it just setups custom presenter mapping). But `provideConfig` metod will work with `Nette\\DI\\CompilerExtension` descendants as well. **And why is this so interesting?** Imagine you have this config in your application (added in bootstrap via `Nette\\DI\\Compiler::addConfig`):\n\n```yaml\nparameters:\n  key1: value1\n  key2: value2\n\nservices:\n  - DefaultService\n  named: Tests\\Service\n\nextensions:\n  ext2: CustomExtension2\n\next2:\n  ext_key1: ext_value1\n  ext_key2: ext_value2\n\napplication:\n  mapping:\n    *: *\n```\n\nAnd now you'll add another config in your DIC extension using `provideConfig` method:\n\n```yaml\nparameters:\n  key2: overridden\n  key3: value3\n\nservices:\n  - Tests\\TestService\n  named: Service2\n\next2:\n  ext_key2: overridden\n  ext_key3: ext_value3\n\nlatte:\n  macros:\n    - App\\Grid\\Latte\\Macros\n```\n\nWhat is the result? Now there are three global parameters:\n\n```yaml\nparameters:\n  key1: value1\n  key2: overridden\n  key3: value3\n```\n\nAs you can see your custom DIC extension has priority. Extensions parameters (`ext2`) behaves exactly the same. What about services? As you can expect there will be three services:\n\n```yaml\n- DefaultService\nnamed: Service2\n- Tests\\TestService\n```\n\nAnd here comes the most interesting part. If you have a lot of extensions it's good idea to use custom config files (it's simple and easy to understand). But it may be hard to get extension configuration from neon file. In `Nette\\DI\\CompilerExtension` descendant class you could do simply `$this-\u003egetConfig()` to get configuration related to the extension, but there is no equivalent for doing this in neon. This extension adds special syntax for this case. From the previous examples there are three options related to the `ext2` extension:\n\n```yaml\next2:\n  ext_key1: ext_value1\n  ext_key2: overridden\n  ext_key3: ext_value3\n```\n\nTo get second parameter into service use this:\n\n```yaml\nservices:\n  - Tests\\TestService(%%ext_key2%%)\n```\n\nRemember that this is possible only if you are using custom config added by `provideConfig` method. It will not work in configs added in bootstrap file (via `Nette\\DI\\Compiler::addConfig`). This is because only under extension it's possible to get key from the right extension section (`ext2.ext_key2` in this case).\n\n### Experimental features\nThese features are not enabled by default now (but may be enabled by default in the future). To enable experimental features now you have to register this extension differently:\n\n```php\n $configurator-\u003edefaultExtensions['extensions'] = [\\Adeira\\ConfigurableExtensionsExtension::class, [TRUE]]; // Become superhero!\n```\n\nAt this moment there is so called `GroupedNeonAdapter`. It allows you to write service definitions in NEON with grouped syntax. Before:\n\n```php\ngraphql:\n  types:\n  - Adeira\\Connector\\Devices\\Infrastructure\\Delivery\\API\\GraphQL\\Type\\WeatherStationRecordType\n  - Adeira\\Connector\\Devices\\Infrastructure\\Delivery\\API\\GraphQL\\Type\\WeatherStationsConnectionType\n  - Adeira\\Connector\\Devices\\Infrastructure\\Delivery\\API\\GraphQL\\Type\\WeatherStationsEdgeType\n  - Adeira\\Connector\\Devices\\Infrastructure\\Delivery\\API\\GraphQL\\Type\\WeatherStationType\n```\n\nAfter:\n\n```php\ngraphql:\n  types:\n    - Adeira\\Connector\\Devices\\Infrastructure\\Delivery\\API\\GraphQL\\Type\\( # namespace must end with backslash\n      WeatherStationRecordType\n      WeatherStationsConnectionType\n      WeatherStationsEdgeType\n      WeatherStationType\n    )\n```\n\nThis feature is optional and works only in NEON files provided via `provideConfig` method. All classes must be registered anonymously. If it's not possible just don't use this feature.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtnzlml%2Fcompiler-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrtnzlml%2Fcompiler-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtnzlml%2Fcompiler-extension/lists"}