{"id":18929544,"url":"https://github.com/thecodingmachine/mvc.silex-mouf","last_synced_at":"2025-09-03T07:36:57.111Z","repository":{"id":57020138,"uuid":"12653107","full_name":"thecodingmachine/mvc.silex-mouf","owner":"thecodingmachine","description":"This project is a very simple extension to the Silex microframework. It adds Mouf dependency injection capability to Silex.","archived":false,"fork":false,"pushed_at":"2013-09-06T20:02:23.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"1.0","last_synced_at":"2025-08-28T17:59:48.784Z","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":"mit","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":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-06T19:55:42.000Z","updated_at":"2013-09-06T20:02:24.000Z","dependencies_parsed_at":"2022-08-22T20:31:17.110Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/mvc.silex-mouf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/mvc.silex-mouf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmvc.silex-mouf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmvc.silex-mouf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmvc.silex-mouf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmvc.silex-mouf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/mvc.silex-mouf/tar.gz/refs/heads/1.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fmvc.silex-mouf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273409639,"owners_count":25100446,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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:27.266Z","updated_at":"2025-09-03T07:36:57.087Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Silex with Mouf Dependency Injection compatibility\n==================================================\n\nThis project is a very simple extension to the [Silex microframework](http://silex.sensiolabs.org/).\nIt adds [Mouf dependency injection](http://mouf-php.com) capability to Silex.\n\nWhy?\n----\n\nSilex is a microframework. It is designed on top of Pimple, a very simple dependency injection container \n(DIC) written in about 80 lines of code.\nPimple is a nice DIC, but it can become quite verbose as your project grows. And natively, Silex\nhas no way to use another DIC (the `Application` class of Silex extends the `Pimple` class).\n\nThis project lets you use [Mouf](http://mouf-php.com), a graphical dependency injection framework\ndirectly in your Silex project. Instead of injecting your dependencies by filling the `$app` variable,\nyou can use Mouf user interface to declare your instances.\n\nHow?\n----\n\nThe extended `Application` class has only one additonnal method: `registerMoufManager()`. This is\nused to register the Mouf DIC instance into Silex.\n\nWhen this is done, you can access any instance declared in Mouf using the `$app` object, just like you would in\nany Silex project.\n\nHere is a sample about injecting a controller in Pimple.\n\n- Install this package using Composer.\n- This package depends on Mouf. Once Mouf is downloaded,\n  you need to [install Mouf](http://mouf-php.com/packages/mouf/mouf/doc/installing_mouf.md).\n- Then, declare a simple test controller:\n  ```php\n  \u003c?php\n  namespace Example\\Controller;\n\n  use Symfony\\Component\\HttpFoundation\\JsonResponse;\n\n  class TestController\n  {\n  \t  private $text;\n  \t  public function __construct($text)\n  \t  {\n  \t\t  $this-\u003etext = $text;\n  \t  }\n\n  \t  public function testAction()\n  \t  {\n  \t\t  return new JsonResponse(array(\"hello\"=\u003e$this-\u003etext));\n  \t  }\n  }\n  ```\n- [Create an instance](http://mouf-php.com/packages/mouf/mouf/version/2.0-dev/doc/mouf_di_ui.md) `mycontroller` for your controller in Mouf.\n  When this is over, you should see this in Mouf UI:  \n  ![Controller's instance](doc/images/mycontroller_instance.png)\n- Init your application using the extended `Mouf\\Silex\\Application` class:\n  ```php\n  // Load Mouf (and Composer's autoloader)\n  require_once __DIR__.'/mouf/Mouf.php';\n\n  // Get Silex app with Mouf support\n  $app = new Mouf\\Silex\\Application();\n\n  // Register Silex's controllers support\n  $app-\u003eregister(new Silex\\Provider\\ServiceControllerServiceProvider());\n\n  // Register the Mouf DI container\n  $app-\u003eregisterMoufManager(Mouf\\MoufManager::getMoufManager());\n\n  // 'mycontroller' instance is declared in Mouf!\n  $app-\u003eget('/hello', \"mycontroller:testAction\");\n\n  $app-\u003erun();  \n  ```\n  \nSee how great it is? You can use the simple routing mechanism of Pimple and get rid of all the\nspaguetti code building your dependencies.\n\n\nKnown limits\n------------\n\nThis project is a proof-of-concept. It prooves that is it possible to chain 2 DI containers easily (this\npackage contains... 10 lines of code!)\nIt also shows the limits of this technique. Indeed, it is not possible from Mouf to refer to an\nobject declared in Pimple (no possible round-trip). This might however become possible, should a \nstandard about DIC interoperability become true.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fmvc.silex-mouf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fmvc.silex-mouf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fmvc.silex-mouf/lists"}