Create Symfony2 Bundle - andyceo/documentation GitHub Wiki
-
The first assumption is that you already have a repository with bundle in it.
-
If so, install Symfony (or maybe you already have Symfony installed).
-
Update
composer.json
file. Create a sectionrepositories
, usually it placed betweenrequire
andscripts
sections and place the LanderBundle repository to the sectionrepositories
:"repositories": [ { "type": "package", "package": { "name": "vendor/your-bundle", "version": "master", "autoload": { "psr-0": { "Vendor\\YourBundle": "" } }, "target-dir": "Vendor/YourBundle", "source": { "url": "[email protected]:vendor/yourbundle.git", "type": "git", "reference": "master" } } } ],
-
In the
require
section ofcomposer.json
, put the LanderBundle with version:"require": { "vendor/your-bundle": "dev-master" },
-
Run
composer update
in Symfony directory. -
Enable the LanderBundle.
// app/AppKernel.php // ... class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = array( // ..., new Vendor\YourBundle\VendorYourBundle(), ); // ... } }
-
Configure the YourBundle if needed (
app/config/config.yml
). -
Include routing from YourBundle to the installed Symfony2 project. In file
app/config/routing.yml
, add following:vendor_your_bundle: resource: "@VendorYourBundle/Resources/config/routing.yml"
-
Install resources:
app/console assets:install
-
Хорошая инструкция по созданию и опубликованию своего бандла: Writing and Publishing Your First Symfony2 Bundle или китайский вариант
-
Мы не будем регистрировать наш бандл на https://packagist.org/, как это делают открытые бандлы (см., например, RpcBundle.php от Sergey Kolodyazhnyy), поэтому надо указать репозиторий в composer.json файле. How to use Composer without Packagist like a Newbie Пример для бандла YourBundle:
"repositories": [ { "type": "package", "package": { "name": "vendor/your-bundle", "version": "master", "autoload": { "psr-0": { "Vendor\\YourBundle": "" } }, "target-dir": "Vendor/YourBundle", "source": { "url": "[email protected]:vendor/yourbundle.git", "type": "git", "reference": "master" } } } ],
-
Еще 3 интересные ссылки: Symfony 2: Bundles (рекомендую!), Symfony 2: Полезные библиотеки и бандлы и Symfony Components