Giedrius
Giedrius

Reputation: 613

Moving default AppBundle under vendor

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

Upvotes: 1

Views: 291

Answers (3)

Giedrius
Giedrius

Reputation: 613

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.

Upvotes: 0

Tomasz Madeyski
Tomasz Madeyski

Reputation: 10910

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)

Upvotes: 1

Ollie in PGH
Ollie in PGH

Reputation: 2629

You can upload your API bundle to a repository (Github, Gitlab, Bitbucket, etc.) and then import it as an external dependency with Composer.

Upvotes: 0

Related Questions