New option asked about several applications when creating a package with Symfony 2.8

Prior to Symfony 2.8 and because I needed a multiApp system in Symfony,

I followed these two posts to achieve this:

- http://jolicode.com/blog/multiple-applications-with-symfony2

- http://mihai-stancu.ro/2015/10/03/multiple-apps-in-one-repo-with-symfony2/

It is not supported by SensioLabs, but it works well, with the console option connected ( php app/console generate:bundle --app=app1 for example) to choose which application you need to use the command in.

Since the advent of Symfony 2.8, I see a new question when creating a package:

Welcome to the symfony package generator!
Do you plan to split this package into multiple applications? [no]:

But I don’t see anything about this feature on the network. Is this related to MultiApp functionality? Any info on this?

Thanks anyway and best regards!

+7
symfony
source share
2 answers

@ michael-sivolobov's answer is very good.

But I want to add more clarity to the answer to the question:

Do you plan to split this package into multiple applications? [Not]:

The Symfony Bundle generator needs to decide whether to use the generated package.

If yes answers this question: this means that your generated Bundle will be used " as is " with several projects, and not just for your current project, so you need the " provider " prefix for the generated package, and also add the prefix to the namespace generated package.

After non-compliance with the agreement, a message will be printed from the console, which reads:

Each package is hosted under a namespace (for example, Acme / BlogBundle). the namespace should begin with the name of the β€œprovider”, such as the name of your company, the name of your project or the name of your customer, followed by one or more optional categories of sub-names of spaces, and it must end with a bunch of the name itself (which should have a Bundle as suffix).

See Best Practice for Package Names for more information on the naming convention kit.

Use / instead of \ for the namespace delimiter to avoid any problems.

The file structure for the generated package in src/ dirctory will be:

 β”œβ”€ src/ β”‚ └─ yourVendor/ β”‚ └─ yourBundle/ β”‚ └─ Controller/ β”‚ └─ DependencyInjection/ β”‚ └─ Resources/ β”‚ └─ Tests/ β”‚ └─ yourVendorYourBundle.php/ 

If you answer this question with No : this means that you intend to use your generated package only for your current project, so you don’t need the supplier’s name as a prefix as it will never be used.

The file structure for the generated package in src/ dirctory will be:

 β”œβ”€ src/ β”‚ └─ yourBundle/ β”‚ └─ Controller/ β”‚ └─ Resources/ β”‚ └─ Tests/ β”‚ └─ yourBundle.php/ 

Here is a good documentation on Project Creation Recommendations .

+9
source share

If you do not know how to answer, use the default value.

This question is here because you can create a package for sharing, and you should call it the name of the provider (like everyone else before the best practices were posted).

But you can also create a package for internal use only as the main package of your application or some useful package. And so you do not need the name of the provider in the name of your package. And answering no to this question, the generator does not generate you YourVendorName/AppBundle , but simply an AppBundle .

Also, if in the xml format a yes response function is formed, and a no response leads to the annotation format.

Therefore, you do not need to worry about multiple applications if you create them as separate packages.

+4
source share

All Articles