{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/19557","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/19557/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/19557/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/19557/events","html_url":"https://github.com/symfony/symfony/issues/19557","id":169781634,"number":19557,"title":"What direction is Symfony heading in? ","user":{"login":"menzow","id":5744434,"avatar_url":"https://avatars.githubusercontent.com/u/5744434?v=3","gravatar_id":"","url":"https://api.github.com/users/menzow","html_url":"https://github.com/menzow","followers_url":"https://api.github.com/users/menzow/followers","following_url":"https://api.github.com/users/menzow/following{/other_user}","gists_url":"https://api.github.com/users/menzow/gists{/gist_id}","starred_url":"https://api.github.com/users/menzow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/menzow/subscriptions","organizations_url":"https://api.github.com/users/menzow/orgs","repos_url":"https://api.github.com/users/menzow/repos","events_url":"https://api.github.com/users/menzow/events{/privacy}","received_events_url":"https://api.github.com/users/menzow/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-08-07T05:48:48Z","updated_at":"2016-08-07T09:12:08Z","closed_at":"2016-08-07T08:59:12Z","body":"Hello,\r\n\r\nAfter almost 1.5 years of not using Symfony, I have a new project that I would like to use symfony for. But after reading up on the best practices for 3.x, and looking at the directory structure I noticed some differences. \r\n\r\nFor embedding assets into your project, it is now advised to use the `/web` directory \"because it makes the lives of designers and frontend developers easier\" .\r\nNow what I remember is that Bundles should be setup in a way that they can run independently from each other or maybe depend loosely on one another.\r\n\r\nNow if I have a bundle that has some custom CSS, that CSS must by put ( according to best practices ) in the Web directory. Making it very difficult to properly deploy that Bundle into multiple projects.\r\n\r\nI also noticed a /tests directory in the root of the project. With a default layout of `/tests/AppBundle/Controller/DefaultControllerTest.php`.\r\n\r\nWhy are tests not in the same directory as the /src/AppBundle/X directory?\r\n\r\nEven the templates for the AppBundle are again placed in the /app/Resources/views directory instead of /src/AppBundle/Resources/views.\r\n\r\nTo me it feels that new developers are giving the instruction to scatter files over the `/app`,`/web`, `/src`, `/tests` directories. Giving a project no clear direction where files are. And projects will not be self contained into one directory.\r\n\r\nWhy is there no clear single /src/AppBundle/ containing all code required to run the bundle?\r\n\r\nWhat is the idea behind this, and what is the direction syfmony developers see this heading in?\r\n\r\nI prefer to have directory structures like this:\r\n```\r\n/src/AppBundle\r\n    /Controller\r\n        ...\r\n    /Entity\r\n        ...\r\n    /Resources\r\n        ...\r\n    ...\r\n```\r\n\r\nOr better;\r\n```\r\n/src/AppBundle/\r\n    /User\r\n        /Entity\r\n            UserEntity\r\n        /Resources\r\n            /config\r\n                product.routes.yml\r\n            /public\r\n                /assets\r\n            /views\r\n                user.list.html.twig\r\n                user.edit.html.twig\r\n                user.create.html.twig\r\n        /Controller\r\n            UserViewController.php\r\n            UserListController.php\r\n            UserEditController.php\r\n    /Products\r\n        /Entity\r\n            ProductEntity.php\r\n        /Service\r\n            ProductService.php\r\n        /Controller\r\n            ProductViewController\r\n            ProductListController.php\r\n            ProductEditController.php\r\n        /Resources\r\n            /config\r\n                product.routes.yml\r\n            /views\r\n                product.list.html.twig\r\n                product.edit.html.twig\r\n                product.create.html.twig\r\n```\r\n\r\nThe last one is purely personal preference, and it doesn't fit anything ever used in Symfony so I understand that something like that would not be introduced. But in the second example, code belonging to anything AppBundle does, is added to the AppBundle directory. Making it easy to re-use in other projects, or remove from the current project entirely."},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/238071973","html_url":"https://github.com/symfony/symfony/issues/19557#issuecomment-238071973","issue_url":"https://api.github.com/repos/symfony/symfony/issues/19557","id":238071973,"user":{"login":"sstok","id":904790,"avatar_url":"https://avatars.githubusercontent.com/u/904790?v=3","gravatar_id":"","url":"https://api.github.com/users/sstok","html_url":"https://github.com/sstok","followers_url":"https://api.github.com/users/sstok/followers","following_url":"https://api.github.com/users/sstok/following{/other_user}","gists_url":"https://api.github.com/users/sstok/gists{/gist_id}","starred_url":"https://api.github.com/users/sstok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sstok/subscriptions","organizations_url":"https://api.github.com/users/sstok/orgs","repos_url":"https://api.github.com/users/sstok/repos","events_url":"https://api.github.com/users/sstok/events{/privacy}","received_events_url":"https://api.github.com/users/sstok/received_events","type":"User","site_admin":false},"created_at":"2016-08-07T09:12:07Z","updated_at":"2016-08-07T09:12:07Z","body":"\"If UserBundle cannot be used \"as is\" in other Symfony apps, then it shouldn't be **its own** bundle.\" \r\n\r\nNotice the \"its own\", in the past many developers have created bundles that depended heavily on each other, \"InvoiceBundle depends on ProductBundle\" but if you only want the InvoiceBundle then you also need the ProductBundle and thus there is coupling between the two.\r\n\r\nIf the InvoiceBundle can be used alone (without depending on other specific bundles), then it's is own bundle, else InvoiceBundle and ProductBundle should be kept together in say a ShoppingBundle (where they share there code and logic).\r\n\r\nIf you take this further you can apply the principle of bounded context: Each Bundle has it's own Entities and Models, and no Bundle may depend on the Entities and Models of another bundle. Instead they are connected (rather then glued) together using a bridge that allows both to communicate together without knowing about each other.\r\n\r\nFor example, I'm building a webhosting management system;\r\n\r\nInstead of making the WebhostingBundle depend on the CustomerBundle, the WebhostingBundle provides an `WebhostingAccountOwner` interface that a bridge Bundle can implement to connect a WebhostingAccount to a eg. Customer, Administrator or anything.\r\n\r\nYou can choose the install WebhostingBundle, and use whatever you like for it's owner.\r\nYes, this makes Doctrine ORM really hard to use as you no longer can do `$account->getCustomer()->getName()` but in the long run the code is more decoupled and easier to change without breaking the whole system.\r\n\r\n\r\nThe Symfony AppBundle is about keeping all application specific code together, without the intention of ever sharing it with other applications. It's the recommended way for RAD (Rapid Application development) and applications that cannot be split further.\r\n\r\nBut for big applications that consist of multiple systems (product, invoice, customer, marketing) it's better to keep each system in it's own bundle without depending on the logic of other bundles.\r\nSo you can at anytime move them to a smaller application, this approach is known as a Hexagonal Architecture](https://youtu.be/fgQWnglnGeU). \r\n\r\nIf you are just getting started with Symfony just use the Best practices, once you gain more experience you can adapt more advanced and decoupled architectures 👍 \r\n\r\nNB. When I talk about other bundles this doesn't include the Framework, TwigBundle etc. But Bundles that were specifically made for the application, and are thus not sharable."}}
{"actor":{"display_login":"sstok"}}