🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@jdreesen
Copy link
Contributor

@jdreesen jdreesen commented Jun 7, 2022

Symfony changed its "Directory Structure Best Practice for Reusable Bundles" in its 4.4 version.

In the old one, everything was just in the bundle root dir / (or maybe inside /src, in which case this was considered "root").
In the new one, the PHP classes moved inside /src and the contents of Resources are unpacked into the root / (with sometimes different names).

Below is a comparison of the old and the new structure:

Symfony < 4.4 Symfony >= 4.4
/
├─ AcmeBlogBundle.php
├─ Controller/
├─ README.md
├─ LICENSE
├─ Resources/
│  ├─ config/
│  ├─ doc/
│  │  └─ index.rst
│  ├─ translations/
│  ├─ views/
│  └─ public/
└─ Tests/
/
├─ config/
├─ docs/
│  └─ index.md
├─ public/
├─ src/
│  ├─ Controller/
│  ├─ DependencyInjection/
│  └─ AcmeBlogBundle.php
├─ templates/
├─ tests/
├─ translations/
├─ LICENSE
└─ README.md

Pimcore doesn't support the new bundle structure at the moment, because it doesn't look at the new locations for Areabricks, config, templates and assets, which means:

  • Areabricks are in /src/Document/Areabrick/ instead of /Document/Areabrick
  • config is in /config instead of /Resources/config/
  • templates are in /templates instead of Resources/views/
  • assets are in /public instead of /Resources/public/

The solution is to look in both possible location, as Symfony does e.g. here, here, here or here.

Resolves #10912

@jdreesen jdreesen force-pushed the bugfix/support-modern-bundele-structure branch from d760b8b to 0e68677 Compare June 27, 2022 08:11
@jdreesen jdreesen changed the base branch from 10.4 to 10.x June 27, 2022 08:12
@dvesh3
Copy link
Contributor

dvesh3 commented Jun 30, 2022

@jdreesen I'm testing your changes but couldn't load bundle public assets properly with new directory structure. On running, assets:install public --symlink I don't see my test bundle(with new directory structure) in the list.

If you look at the Symfony code it looks for public folder in /src it seems.

This how i autoload my bundle namespace in composer.json:

  "autoload": {
    "psr-4": {
      "Test\\TestBundle\\": "src/"
    }
  },

Could you please confirm if putting public folder outside /src works for you?

@jdreesen
Copy link
Contributor Author

jdreesen commented Jun 30, 2022

Yes, it works. Did you configure your bundle path in *Bundle::getPath() as described here?

Note
This is the default since Symfony 6.1+ (when you extend AbstractBundle). Before, you have to configure that manually.

@dvesh3
Copy link
Contributor

dvesh3 commented Jun 30, 2022

Yes, it works. Did you configure your bundle path in *Bundle::getPath() as described here?

Note
This is the default since Symfony 6.1+ (when you extend AbstractBundle). Before, you have to configure that manually.

yes, I missed that point 🤦‍♂️ it works now. thank you!!

@dvesh3 dvesh3 merged commit 7d5f808 into pimcore:10.x Jun 30, 2022
@dvesh3
Copy link
Contributor

dvesh3 commented Jun 30, 2022

@jdreesen nice work 🚀 thanks a lot!

@jdreesen jdreesen deleted the bugfix/support-modern-bundele-structure branch June 30, 2022 14:48
@kingjia90 kingjia90 mentioned this pull request Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Areabrick autoloading is not compatible with the directory structure as described in Symfony's best practices for bundles

3 participants