0

I have seen that new symfony projects have a diffrent directory stucture. Mainly the ressources-folder is not used anymore. I personally found that old structuring very nice, since all ressources were where they were used. When I start using bundles. it feels wrong to have all in the root folder. This is clearly an opinion, but I got a question from that, and the following question is not about opinion, but in practicality of the old structure in Symfony > 6:

What is the benefit of the new folder structure compared to the old approach with src/Ressources? Is there an advantage to the new structure which I don't see, or is it just a matter of taste and i can go the old way?

Your inputs are highly appreciated


Old approach

    Root/
    ├─ src/
    │  ├─ Ressources/
    │  │  ├─ config/
    │  │  ├─ public/
    │  │  ├─ js/
    │  │  ├─ styles/
    │  │  ├─ views/
    │  │  ├─ translations/

New approach

    Root/
    ├─ src/
    ├─ public/
    ├─ templates/
    ├─ translations/
    ├─ config/
endo.anaconda
  • 2,449
  • 4
  • 29
  • 55
  • 1
    This is an opinion based question and will probably be closed once the closers are back from vacation. Might be better to post on Symfony Reddit. Your Symfony 3 tag confused me. The default bundle structure changed between 6.0 and 6.1. I know it was talked about making the changes just to make bundles more consistent with the application layout. As mentioned in the answer you can still use the old layout. Even the Symfony bundles have not been updated. I personally always thought having to have a Resources folder to be a bit annoying. – Cerad Aug 06 '22 at 01:44

1 Answers1

1

First of all, you can use old structure in new Symfony versions too! It all depends on few configurations.

To me, new structure is better, it makes more sense to move most things out of Resources directory into assets.

So it should really be:

├─ root/
│  ├─ config/
│  ├─ src/
│  ├─ public/
│  ├─ views/
│  ├─ translations/
│  ├─ assets/
│  │  ├─ js/
│  │  ├─ styles/
HelpNeeder
  • 6,383
  • 24
  • 91
  • 155
  • 1
    I don't understand your remark. The [new structure](https://symfony.com/doc/current/bundles.html#bundle-directory-structure) still uses public for stashing js and styles meant to be copied/linked into the application's public folder. The recently added and somewhat confusingly named `assets` folder is for `Contains JavaScript, CSS, images and other assets related to the bundle that are not in public/ (e.g. stimulus controllers)`. Stimulus controllers` appear to be some sort of javascript controller. – Cerad Aug 06 '22 at 13:00
  • @Cerad -- It's not that confusing if you understand that styles/javascript/vue gets compiled and then dumped into `public/{css/js}`. Basically, `root/public` should never be modified, anything there should be automated. If you have some resources like images that used to go into Resources/public folder, those need to be copied into public, for example by using webpack something like `.copyFiles({from: 'node_modules/tinymce/skins/ui/oxide',to: 'tinymce/[path][name].[ext]'})`. The point was, that assets are assets, SRC has php files, views is for templates etc. Everything makes sense. – HelpNeeder Aug 07 '22 at 14:08