Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install a composer package into the /src dir?

How do I have do modify my composer.json to install directly into the src-dir (Symfony/src)?

{
"name": "acme/example-bundle",
"type": "symfony-bundle",
"license": "MIT",
"require": {
    "php": ">=5.3.2",
    "symfony/framework-bundle": "2.1.*"
},
"suggest": {
    "doctrine/doctrine-bundle": "*"
},
"autoload": {
    "psr-0": { "Acme": "src/" }
},
"target-dir": "../../src/Acme/ExampleBundle"

}

like image 415
bodokaiser Avatar asked Dec 12 '22 01:12

bodokaiser


2 Answers

actually it's not a good idea to install vendor packages to the src dir because vendor packages should not be edited and the src directory is meant for code that is edited in the development process.

one reason that comes to my mind is that you want do modify these packages. if this is the point, you'd better be off using git submodules because composer only has a one way flow, meaning changes can only come from the source of the vendor package and there is no upstream to the source.

i use git submodules for the bundles in my projects that are not project specific and thus reside in their own git repository but are actively developed during in the project.

like image 191
room13 Avatar answered Dec 17 '22 05:12

room13


The src directory of a PHP/Symfony project is typically used only for the code of that project. Code you install as a dependency goes into the vendor directory.

This makes it easy to keep track of which code is part of the project itself and which code is maintained in a separate repository.

As such you should not install a bundle from a separate repository into your src directory. Bundles in Symfony work just fine if they are located in the vendor directory just like many of the core framework bundles.

like image 41
naderman Avatar answered Dec 17 '22 07:12

naderman