In this blog post I will explain how to create your own reusable vendor bundle in symfony 2 and using git as scm.
Step 1: Create an empty git repo on your server.
Create an empty directory for your remote repository, naming it with your bundle name.
mkdir VendorNameBundleNameBundle.git
change into that directory and initialize the repository
git init --bare --shared=group
Clone the repo on your dev machine
Clone your newly created git repository on your local machine and change into that directory. Add a file composer.json
with the following information
{ "name": "vendorname/bundlename-bundle", "description": "Bundle description", "type": "symfony-bundle", "authors": [ { "name": "Your Name", "email": "Your email", "homepage": "Your homepage" } ], "autoload": { "psr-4": { "VendorName\\BundleNameBundle\\": "" } }, "require": { "required/bundles-bundle": "~1.0" } }
And add a Bundle class in VendorNameBundleNameBundle.php:
<?php namespace VendorName\BundleNameBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class VendorNameBundleNameBundle extends Bundle { }
Commit these files and push your changes to your remote repo.
Require your bundle in your symfony app
Add your remote repository to the composer.json of your symfony application.
{ ... "repositories": [ ... { "type": "vcs", "url": "url to your remote repository" }, ... ], ... }
Add your bundle ass requirement to your symfony application
composer require "vendorname/bundlename-bundle":"dev-master"