Brent Heigold
Brent Heigold

Reputation: 1273

Bundles are not encouraged in Symfony 4, why is that? And what replaces them?

In practicing with Symfony 4.1 I noticed how it says on the bundles page: (https://symfony.com/doc/current/bundles.html)

In Symfony versions prior to 4.0, it was recommended to organize your own application code using bundles. This is no longer recommended and bundles should only be used to share code and features between multiple applications.

Why is that and what is to replace bundles? Simply create directories inside one "App" bundle?

So a mere subfolder replaces a bundle?

Upvotes: 1

Views: 2769

Answers (2)

masoodahm
masoodahm

Reputation: 305

The answer to your question is written at the bottom of this page here on symfony site. To Summarize

But a bundle is meant to be something that can be reused as a stand-alone piece of software. If UserBundle cannot be used "as is" in other Symfony apps, then it shouldn't be its own bundle. Moreover, if InvoiceBundle depends on ProductBundle, then there's no advantage to having two separate bundles.

and then

Don't create any bundle to organize your application logic.

Symfony applications can still use third-party bundles (installed in vendor/) to add features, but you should use PHP namespaces instead of bundles to organize your own code.

So to Answer your question "So a mere subfolder replaces a bundle?" Yes! if its a reusable piece of code that can be used by other applications make it into a bundle otherwise if its just there to organize the application, use folders (with namespaces) for that.

Upvotes: 5

Julien Ho
Julien Ho

Reputation: 31

you can see the demo app here -> https://github.com/symfony/demo

Upvotes: 2

Related Questions