We split our logic in project into "bundles" and installing them using composer.
But we problem with DB scheme creation, because doctrine will not create scheme for entities in vendor dir.
And we have problem with getting repository, because getRepository with argument like this Company\SomeModuleBundle\Entity\Comment will fail with message The class 'Company\SomeModuleBundle\Entity\Comment' was not found in the chain configured namespaces (...)
How can we achieve creating schemes from our bundles (installed with composer) and accessing them?
Thank you!
I forgot add bundle into AppKernel, thats it.
Thanks #Cerad.
Related
I would like to know if there's a way to create a reusable bundle that depends on a public bundle in my case, OneupFlysystemBundle ?
By adding OneupFlysystemBundle to my bundle's composer.json I can see that it's downloaded and present in the vendor folder.
I want to only include my own bundle in the AppKernel (which has a dependency on OneupFlysystemBundle)
Beside these solutions I ended using the non-bundle (library) version of OneupFlysystem as a dependency of my bundle and rewrite it as facade
Probably the best way is to use Symfony Flex. Which allows you to use recipes. An alternative would be to use symfony-bundle-dependencies
I have a new symfony project. By default it contains
-/AppBundle
-AppBundle.php
--/Controller
--/Default Controller
Since I am going to have more bundles I would like it to be under a VendorName called MyProject where I have my ApiBundle.
I have tried moving AppBundle manually, then changing namespaces in the files, yml files and AppKernel. But I still get an error
Expected to find class "AppBundle\AppBundle" in file "/Applications/MAMP/htdocs/healthy-living/src/HealthyLiving/AppBundle/AppBundle.php" while importing services from resource "../../src/HealthyLiving/AppBundle/*", but it was not found! Check the namespace prefix used with the resource.' in /Applications/MAMP/htdocs/healthy-living/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php:133
Is there any console commands for doing this, if not what should be the procedures of moving it.
Thanks in advance
There's no console command or procedure to do it because it's not what vendor folder was designed for. vendor folder is meant to store 3rd-party code so keeping your own bundles, which you are developing, in vendor is not a good idea.
Since I am going to have more bundles
There is no reason that you can't keep more than one bundle inside your src folder. In fact, when Symfony introduced Bundle system it was very common that src folder contained a lot of bundles.
(note that vendor folder is almost always added to .gitignore - that's because what I wrote before)
EDIT after clarifying what the question is about:
It looks like command to generate bundles has/had some issues with creating bundles without Vendor folder:
Issue
Pull request
I don't know which version of Symfony are you using but either way creating bundle manually is always a good idea and it solves your problem too. (you can create it without vendor name)
You can upload your API bundle to a repository (Github, Gitlab, Bitbucket, etc.) and then import it as an external dependency with Composer.
Since moving was too complicated because of the config files that has to be changed so I decided to do a workaround and remove it and then install via console under the same parent. Works like a charm. Althoug could be a method in cli for this.
I need to keep in sync the same models between two symfony2 applications located in two different server.
I think to use Git for this work with something like "repository inside a repository".
This is a viable method?
Anyone has already done something of similar?
Put the models in an extra bundle and git repository. Then refer to it via composer and it will be installed in de vendor dir of the two projects. After that you need only to edit the extra bundle.
http://knpuniversity.com/screencast/question-answer-day/create-composer-package
Learning Symfony2 and Sylius at the same time here. Thanks for your patience.
What brought me to this question is the desire to override some of Sylius's default functionally. The first of which I am focusing on is tax behavior. I want to accommodate specific tax rates for several different on the ground stores. As I understand it, if I want to be able to update future changes in Sylius, I don't want to modify code in sylius/src/Sylus/* correct? I think I understand how to make the overrides, but I cannot seem to generate my own bundle with Sylius.
ubuntu#ubuntu-VirtualBox:/var/www/sylius$ php app/console generate:bundle
[InvalidArgumentException]
Command "generate:bundle" is not defined.
I can run the same command in a generic Symfony2 install I have, and it works.
Am I doing something wrong / something is broken, or has bundle generation been removed from Sylius and it is expected that bundles be written all manually?
Thanks, and any links to further reading on this are appreciated.
You need to install SensioGeneratorBundle if you want this feature. This bundle is not included in standard Sylius distribution. Installation and their usage is pretty straightforward ;)
Yup, I think you shouldn't edit core bundles but instead override whatever you want - see here how to achieve that. Sylius is built with good design so overriding could be easily achieved by simply having your own DI class parameter instead of core class.
Cheers!
I'm on Symfony 2.0 and understood that third-party libraries go in /vendor. I have two third party classes I'm using, one is TCPDF and another is a Paypal class. Neither have formal Symfony2 Bundles.
So I followed the instructions here which namespaces them and makes them usable inside /vendor:
Add third party libraries to Symfony 2
This works and I can access them from my Controllers. However I'm rethinking if that's the right thing. Whenever I do..
php bin/vendors install --reinstall
..those custom classes disappear because they don't have a Git repo in 'deps'. This has caused real problems e.g. when trying to deploy on e.g. PagodaBox. I get the strong instinct that this code while 'third-party' belongs closer to the code of my app.
If that's true, should it:
Sit next to my Controllers in src/MyCompany/MyBundle/Controller/tcpdf.php
Be with my other custom-written services in src/MyCompany/MyBundle/DependencyInjection/tcpdf.php
Go in its own directory under my bundle: src/MyCompany/MyBundle/TCPDF/tcpdf.php
If I move these two classes from /vendor to one of the above, would I access it from a Controller with a 'use' statement, or would I need to define it in 'services.yml'?
I hope this isn't so much a matter of discussion or opinion but some guidance I've missed or best practise I'm unaware of that a more experienced Symfony2 dev would know.
Would it be sensible to switch to Composer even before Symfony 2.1 is ready?
Thanks for reading.
If you're using deps to manage vendor libraries then you should add the git repo's for those libraries there.
For TCPDF you can use:
[TCPDF]
git=git://tcpdf.git.sourceforge.net/gitroot/tcpdf/tcpdf
target=/tcpdf
If you have other libraries that aren't in a public repo then you may want to commit them to your own repo.
The same would hold true for Composer. Just the syntax for adding non-packagist repo's is different.