Asked  8 Months ago    Answers:  5   Viewed   34 times

We're considering creating our own common bundle for entity mapping and services for use within few separate apps. A bundle should be easy to modify, run, include and test. I know about Best Practices for Structuring Bundles, but I don't know what git strategy to use when it comes to development.

Should we create common bundle as a whole project and commit whole repository to our git server, or is it better to start source control only for root of common bundle and push only its contents? I see this approach in bundles available on github, but I don't know easy and comfortable way to develop bundles that way.



Create a new empty symfony project

php composer.phar create-project symfony/framework-standard-edition demo/ 2.4.1
cd demo

Generate a new bundle

(for example src/Company/DemoBundle)

php app/console generate:bundle
cd src/Company/DemoBundle/

Init your github repository in src/Company/DemoBundle

git init
git add .
git commit -m "initial commit"
git remote add origin
git push -u origin master

Add a composer.json file


    "name" : "company/demobundle",
    "description" : "A demo bundle",
    "type" : "symfony-bundle",
    "authors" : [{
        "name" : "demo",
        "email" : ""
    "keywords" : [
        "demo bundle"
    "license" : [
    "require" : {
    "autoload" : {
        "psr-0" : {
            "Company\DemoBundle" : ""
    "target-dir" : "Company/DemoBundle",
    "repositories" : [{
    "extra" : {
    "branch-alias" : {
            "dev-master" : "some_version-dev"

Now you have the base structure of your bundle

Use it in another project


    "require" : {
        "company/demobundle" : "dev-master"
    "repositories" : [{
        "type" : "vcs",
        "url" : ""


curl -sS | php
php composer.phar update company/demobundle


new CompanyDemoBundleCompanyDemoBundle(),

Work on it

  • You can clone your DemoBundle in the src/Company folder, then manually install it
  • You can use symlink


You can develop and test your bundle in your first project and use it with github and composer in your second project.

Wednesday, March 31, 2021
answered 8 Months ago

The files under vendor/ aren't supposed to be tracked, i.e. it's supposed to be in your .gitignore file. Instead, the composer utility should be used to download the packages and install them.

In your case I would suggest to:

  1. Unpack the project into a temporary directory,
  2. Run composer install
  3. Deploy the temporary directory contents.
Saturday, May 29, 2021
answered 5 Months ago

You can also use GIT SUBMODULES within your project A to refer to project B and then add


to the gitlab-ci.yml file in project A.

This also enables you to specifically include a specific branch or commit from your subproject.

Tuesday, August 17, 2021
answered 3 Months ago

Turns out this is not yet supported, scheduled for v1.1

Sunday, September 19, 2021
answered 1 Month ago

More than one of the approaches in my question will work. Some will not, some do not currently due to defects in Angular 2. Here's the approach I'm currently using:

WebPack + require.js


var config = {
    entry: {
        app: inputFile
    externals: [
    output: {
        libraryTarget: "amd",
        path: __dirname,
        filename: './' + outputName
    plugins: [
        new require('webpack').optimize.UglifyJsPlugin()

I only tell it what are externals and what pseudo-standard mechanism will load them at runtime via libraryTarget (AMD/RequireJS, CommonJs/node, UMD). My setting simply causes external library references to be wrapped in define().

Note that I don't do anything with paths in WebPack. In my software, anything in the node_modules folder has a similar reference mechanism both in my software and in third party modules, internally. Both my code and third-party libraries expect to find RxJS at rxjs (e.g. rather than ../rxjs or 'node_modules/rxjs`). At runtime, both need to be mapped, but since we aren't allowing WebPack to reach into third party modules (we're using pre-built UMD's), WebPack isn't the place to do that mapping. It would only map my code. Instead, we should do that in our runtime loader:


<script src=""></script>
<script src=""></script>
<script src=""></script>
    var require = (function(){
        var versions = {
            'router-deprecated': '@@2.0.0-rc.2',
            'forms': '@@0.1.1',
            'angular': '@@2.0.0-rc.4',
            'rxjs': '@@5.0.0-beta.10'

        var paths = {
            'rxjs': "" + versions.rxjs + "/bundles/Rx.umd.min"
        ].forEach(function (submodule) {
            var module = '@@angular/' + submodule
            paths[module] = '' + module + (versions[submodule] || versions.angular) + '/bundles/' + submodule + '.umd.min';

        var rxmap = {};
        ].forEach(function (submodule) {
            rxmap['rxjs/' + submodule] = 'rxjs';

        return {
            paths: paths,
            map: {
                '*': rxmap
<script data-main="../assets/compiled/a2.webpack.js" src=""></script>

Also, since if you are using WebPack and UMDs you probably care about resulting file sizes and times. This sub-app's Angular 2 build process went from about 24 seconds to 1 second. Its publish changed-size went from over 2MB to about 100k.

Here are wire load sizes of the cached dependencies for reference. Strangely they are currently a few KB smaller in the UMD version than the wire-size increase of an integrated, WebPack pruned, bundle.

27.5 shim
 6.8 zone
 8.0 require
 3.3 platform-browser-dynamic
36.8 http
 8.7 core
20.8 common
16.5 router
98.5 compiler
27.9 platform-browser
39.0 Rx

Obviously my public site load times after updates are drastically reduced (down to 1 second from about 10-20 seconds), but those numbers are pretty variable based on connection.

Wednesday, September 22, 2021
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :