2
Even after reading the best practices for code reuse in symfony and research on the use of commiserate, I still can’t understand how in practice I should create my Barcode to be reusable. I know the way I do it is not ideal and I wanted to do it the right way, but I’m having a hard time understanding how I should do it.
Today I do it this way:
- I create a project using the symfony model.
composer create-project symfony/framework-standard-edition projects/symfony2 "2.8.*"
- I create a Bundle with the namespace I want
app/console generate:bundle --namespace=Vendor\Bundle\MeuModuloBundle --format=annotation
- I change the filename of the package in the Composer.json, the description and add the dependencies I need (only this) and then update Composer to install the dependencies.
composer update
I initialize the Bundles of the dependencies I put in Appkernel.php
I work on the business rules of my Bundle (Vendor Bundle Meumodulobundle)
I eat and it is ready my Bundle.
If I need to reuse Bundle I add its name in Composer (as I described in Vendor.json (Vendor Bundle Meumodulobundle) and run the Composer update command. (Satis stores the packets)
The problem in all this is that the code goes full of garbage, with the app folder, src, the conflict with appKernel and etc... because in reality it is a treats as a project (because I did so the wrong way for what I want) I want to actually reuse it as a module, but I don’t know how to do exactly, because I need to create a module but I want to be able to use Doctrine, route, fosrest and other features that are already ready in symfony.
How should I proceed to do right?
Good practices exhibit the folder structure that must be created in order for the project to be compatible with symfony one of my questions is how would I create a clean project, for example: Would I have to create a standard structure and not use the symfony model? where would I put the config.yml configuration files, Parameter.yml, Appkernel, how would Composer.json, autoload, app.php, app_dev.php, console and etc... used today, or it would be replaced by what? that is the question in itself.
You are using Symfony 2.8 (you can check the code you posted from the Composer command), however the version you read about good Symfony practices (at least the link is the link that is in the question) was for the version "Current", which at the time of writing the commentary is 3.2. Symfony 2.8 version is different from 3.*, so I recommend reading the good practices for the version you are using: https://symfony.com/doc/2.8/bundles/best_practices.html
– Filipe Moraes
@Filipemoraes Thank you for the comment. The best practices exhibit the folder structure that must be created in order for the project to be compatible with symfony version 2.8 and 3.2 in this aspect does not influence much, because my doubt is how I would create a clean project, for example: Would I have to create a standard structure and not use the symfony model? where would I put the appKernel configuration files used today, or it would be replaced by what? that’s the question itself.
– Sileno Brito