创建一个新的空 symfony 项目
php composer.phar create-project symfony/framework-standard-edition demo/ 2.4.1
cd demo
生成一个新的包
(例如src/Company/DemoBundle
)
php app/console generate:bundle
cd src/Company/DemoBundle/
初始化你的 github 存储库src/Company/DemoBundle
git init
touch README.md
git add .
git commit -m "initial commit"
git remote add origin https://github.com/YourAccount/DemoBundle.git
git push -u origin master
添加composer.json文件
src/Company/DemoBundle/composer.json
:
{
"name" : "company/demobundle",
"description" : "A demo bundle",
"type" : "symfony-bundle",
"authors" : [{
"name" : "demo",
"email" : "[email protected]"
}],
"keywords" : [
"demo bundle"
],
"license" : [
"MIT"
],
"require" : {
},
"autoload" : {
"psr-0" : {
"Company\\DemoBundle" : ""
}
},
"target-dir" : "Company/DemoBundle",
"repositories" : [{
}],
"extra" : {
"branch-alias" : {
"dev-master" : "some_version-dev"
}
}
}
现在您已经有了捆绑包的基本结构
在另一个项目中使用它
作曲家.json:
[...]
"require" : {
[...]
"company/demobundle" : "dev-master"
},
"repositories" : [{
"type" : "vcs",
"url" : "https://github.com/Company/DemoBundle.git"
}],
[...]
Do:
curl -sS https://getcomposer.org/installer | php
php composer.phar update company/demobundle
应用程序/应用程序内核:
new Company\DemoBundle\CompanyDemoBundle(),
在...上下功夫
- 您可以在以下位置克隆您的 DemoBundle
src/Company
文件夹,然后手动安装
- 您可以使用符号链接
结论
您可以在第一个项目中开发和测试您的捆绑包,并在第二个项目中将其与 github 和作曲家一起使用。