{"action":"created","issue":{"url":"https://api.github.com/repos/contao/core-bundle/issues/455","repository_url":"https://api.github.com/repos/contao/core-bundle","labels_url":"https://api.github.com/repos/contao/core-bundle/issues/455/labels{/name}","comments_url":"https://api.github.com/repos/contao/core-bundle/issues/455/comments","events_url":"https://api.github.com/repos/contao/core-bundle/issues/455/events","html_url":"https://github.com/contao/core-bundle/pull/455","id":138308687,"number":455,"title":"[RFC] Autoloading of system/modules","user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/contao/core-bundle/labels/feature","name":"feature","color":"3364b7"}],"state":"open","locked":false,"assignee":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2016-03-03T21:56:36Z","updated_at":"2016-04-25T11:22:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/contao/core-bundle/pulls/455","html_url":"https://github.com/contao/core-bundle/pull/455","diff_url":"https://github.com/contao/core-bundle/pull/455.diff","patch_url":"https://github.com/contao/core-bundle/pull/455.patch"},"body":"This is a very early draft to show autoloading of `system/modules` using https://github.com/mmoreram/symfony-bundle-dependencies\r\n\r\nThe great thing about this is that it allows for full flexibility for developers while providing easy installation for regular users. If you do not want bundle autoloading at all, simply do not use the trait. If you do not want autoloading of `system/modules`, simply do not load the `ContaoModuleAutoloadBundle`.\r\n\r\nFor a regular user though, this means using composer to install a legacy extension (like currently possible) will **automatically** enable it like in all previous Contao versions. I think that's a big step forward to the acceptance of Contao 4.\r\n\r\n### Testing\r\n\r\nThe following changes to your installation are required to test this. I have added **one** module to `system/modules` and it was automatically loaded (see tasks about multiple modules).\r\n\r\n1. Adjust your `composer json`\r\n\r\n    ```json\r\n    \"require\": {\r\n        \"contao/core-bundle\": \"dev-bundle-dependencies as 4.2.9999\"\r\n    },\r\n    \"repositories\": [\r\n        {\r\n            \"type\": \"vcs\",\r\n            \"url\": \"https://github.com/aschempp/contao-core-bundle.git\"\r\n        }\r\n    ],\r\n    \"minimum-stability\": \"dev\",\r\n    \"prefer-stable\": true\r\n    ```\r\n\r\n2. Adjust your `AppKernel.php`\r\n\r\n    ```php\r\npublic function registerBundles()\r\n    {\r\n        global $loader;\r\n\r\n        if ($loader instanceof \\Composer\\Autoload\\ClassLoader) {\r\n            $loader->addPsr4('Contao\\CoreBundle\\HttpKernel\\Bundle\\\\', $this->getCacheDir() . '/contao/bundles');\r\n        }\r\n\r\n        $bundles = [\r\n            'Lexik\\Bundle\\MaintenanceBundle\\LexikMaintenanceBundle',\r\n            'Sensio\\Bundle\\FrameworkExtraBundle\\SensioFrameworkExtraBundle',\r\n            'Contao\\CoreBundle\\ContaoCoreBundle',\r\n            'Contao\\CalendarBundle\\ContaoCalendarBundle',\r\n            'Contao\\CommentsBundle\\ContaoCommentsBundle',\r\n            'Contao\\FaqBundle\\ContaoFaqBundle',\r\n            'Contao\\ListingBundle\\ContaoListingBundle',\r\n            'Contao\\NewsBundle\\ContaoNewsBundle',\r\n            'Contao\\NewsletterBundle\\ContaoNewsletterBundle',\r\n            'Contao\\CoreBundle\\HttpKernel\\Bundle\\ContaoModuleAutoloadBundle',\r\n        ];\r\n\r\n        return $this->getBundleInstances($this, $bundles);\r\n    }\r\n    ```\r\n\r\n3. Update composer dependencies (obviously)\r\n\r\n\r\n### Open questions / tasks\r\n- [x] `ContaoModuleBundle` should parse `autoload.ini` to add dependencies of a module. Probably restore our drafts from early 2015 to parse the ini-file dependencies (see https://github.com/contao/core-bundle/tree/feature/symfony2/src/Autoload).\r\n- [x] Discuss if we should keep the core bundles (like `FrameworkBundle`) in the `AppKernel`. They **must** be in `ContaoCoreBundle` though, otherwise the order of loading would not be correct.\r\n- [x] Check if the current dependency resolver library does correctly resolve multiple times the same class with different constructor arguments."},"comment":{"url":"https://api.github.com/repos/contao/core-bundle/issues/comments/214271985","html_url":"https://github.com/contao/core-bundle/pull/455#issuecomment-214271985","issue_url":"https://api.github.com/repos/contao/core-bundle/issues/455","id":214271985,"user":{"login":"leofeyer","id":1192057,"avatar_url":"https://avatars.githubusercontent.com/u/1192057?v=3","gravatar_id":"","url":"https://api.github.com/users/leofeyer","html_url":"https://github.com/leofeyer","followers_url":"https://api.github.com/users/leofeyer/followers","following_url":"https://api.github.com/users/leofeyer/following{/other_user}","gists_url":"https://api.github.com/users/leofeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/leofeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leofeyer/subscriptions","organizations_url":"https://api.github.com/users/leofeyer/orgs","repos_url":"https://api.github.com/users/leofeyer/repos","events_url":"https://api.github.com/users/leofeyer/events{/privacy}","received_events_url":"https://api.github.com/users/leofeyer/received_events","type":"User","site_admin":false},"created_at":"2016-04-25T11:22:57Z","updated_at":"2016-04-25T11:22:57Z","body":"> After investigating the options of the same bundle with different constructor argument, I decided to go with the bundle class generator.\r\n\r\nWhen we discussed it, however, we explicitly decided against class generation."}}