{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/282","labels_url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/282/comments","events_url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/282/events","html_url":"https://github.com/doctrine/DoctrineBundle/issues/282","id":30099304,"number":282,"title":"Can't load entities from bundles using PSR-4","user":{"login":"arthens","id":1178572,"avatar_url":"https://avatars.githubusercontent.com/u/1178572?v=3","gravatar_id":"","url":"https://api.github.com/users/arthens","html_url":"https://github.com/arthens","followers_url":"https://api.github.com/users/arthens/followers","following_url":"https://api.github.com/users/arthens/following{/other_user}","gists_url":"https://api.github.com/users/arthens/gists{/gist_id}","starred_url":"https://api.github.com/users/arthens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthens/subscriptions","organizations_url":"https://api.github.com/users/arthens/orgs","repos_url":"https://api.github.com/users/arthens/repos","events_url":"https://api.github.com/users/arthens/events{/privacy}","received_events_url":"https://api.github.com/users/arthens/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2014-03-25T06:11:53Z","updated_at":"2016-01-13T14:57:38Z","closed_at":"2014-04-27T20:10:45Z","body":"According to [PSR-4](https://github.com/php-fig/fig-standards/blob/master/proposed/psr-4-autoloader/psr-4-autoloader.md), the namespace of a class doesn't have to be a direct mapping to the filesystem. See the [first example of the specs](https://github.com/php-fig/fig-standards/blob/master/proposed/psr-4-autoloader/psr-4-autoloader.md#3-examples)\r\n\r\nThis doesn't look to be supported because of:\r\nhttps://github.com/doctrine/DoctrineBundle/blob/master/Mapping/DisconnectedMetadataFactory.php#L143\r\n\r\nThis method tries to remove the namespace from the path, and fails because it can't find it.\r\n\r\ne.g. of a bundle using PSR-4 and `VendorName\\BundleName` as a prefix\r\n```php\r\n$namespace = \"VendorName\\BundleName\\Entity\";\r\n$path = \"/site/vendor/vendorname/bundlename/Entity\";\r\n```\r\n\r\nwill fail because there's no direct mapping"},"comment":{"url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/comments/171320466","html_url":"https://github.com/doctrine/DoctrineBundle/issues/282#issuecomment-171320466","issue_url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/282","id":171320466,"user":{"login":"janvennemann","id":1406024,"avatar_url":"https://avatars.githubusercontent.com/u/1406024?v=3","gravatar_id":"","url":"https://api.github.com/users/janvennemann","html_url":"https://github.com/janvennemann","followers_url":"https://api.github.com/users/janvennemann/followers","following_url":"https://api.github.com/users/janvennemann/following{/other_user}","gists_url":"https://api.github.com/users/janvennemann/gists{/gist_id}","starred_url":"https://api.github.com/users/janvennemann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janvennemann/subscriptions","organizations_url":"https://api.github.com/users/janvennemann/orgs","repos_url":"https://api.github.com/users/janvennemann/repos","events_url":"https://api.github.com/users/janvennemann/events{/privacy}","received_events_url":"https://api.github.com/users/janvennemann/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T14:57:38Z","updated_at":"2016-01-13T14:57:38Z","body":"Here is a fix for PSR-4 compatibility which acts as an optional lookup before the default PSR-1 path generation. It uses the composer autoloader to check for registered PSR-4 prefix paths. If for some reason no composer autoloader is present it continues to generate base paths the old way. It's therefore fully backwards compatible.\r\n\r\nhttps://gist.github.com/janvennemann/46b2626eee2a4808ed75\r\n\r\nThe entity and crud controller generators work out of the box with this fix. The path passed to the entity repository generator is still wrong and needs to be fixed, but i don't need that at the moment so i haven't done that yet."}}