Ily*_*hin 7 php composer-php symfony-2.1
我刚刚转到Symfony 2.1,我无法理解,如何在Composer中安装自己的软件包?
在2.0.x中非常容易deps:
[MyOwnBundle]
git=git@git.weboshin.ru:weboshin_cms_bundle.git
target=/bundles/My/OwnBundle
Run Code Online (Sandbox Code Playgroud)
之后我才触发了bin/vendors update,就是这样!
但现在没有deps文件,我应该用Composer做所有事情.请给我任何提示.
我找到了答案.
// my_project/compose.json:
{
"repositories": [
{
"type": "vcs",
"url": "own_repository_url"
}
],
// ...
"require": {
// ...
"own/bundle": "dev-master"
}
},
Run Code Online (Sandbox Code Playgroud)
// own_repository/own_bundle/compose.json:
{
"name": "own/bundle"
}
Run Code Online (Sandbox Code Playgroud)
将composer.json文件添加到您的包中.例如,我有一个我的捆绑包:
{
"name": "cg/kint-bundle",
"type": "symfony-bundle",
"description": "This bundle lets you use the Kint function in your Twig templates. Kint is a print_r() replacement which produces a structured, collapsible and escaped output",
"keywords": ["kint", "debug", "symfony", "bundle", "twig"],
"homepage": "http://github.com/barelon/CgKintBundle",
"license": "MIT",
"authors": [
{
"name": "Carlos Granados",
"homepage": "http://github.com/barelon"
},
{
"name": "Symfony Community",
"homepage": "http://github.com/barelon/CgKintBundle"
}
],
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": ">=2.0.0",
"raveren/kint": "dev-master"
},
"minimum-stability": "dev",
"autoload": {
"psr-0": {
"Cg\\KintBundle": ""
}
},
"target-dir": "Cg/KintBundle"
}
Run Code Online (Sandbox Code Playgroud)
然后将您的包添加到packagist.org.这很简单,基本上你只需要提供你的git地址,它将完成其余的工作.
一旦您的包在packagist中可用,那么只需将它作为依赖项添加到symfony项目的composer.json文件中.就我而言,我有:
"require": {
....
"cg/kint-bundle": "*"
},
Run Code Online (Sandbox Code Playgroud)
然后在你的symfony目录中运行"composer update"就可以了!你甚至不需要更新自动加载文件,作曲家会为你做.唯一剩下的就是在appkernel.php中加载bundle
| 归档时间: |
|
| 查看次数: |
10789 次 |
| 最近记录: |