7

Symfony 2.1 に移行したばかりですが、理解できません。Composer で独自のバンドルをインストールするにはどうすればよいですか?

2.0.x では非常に簡単でしたdeps:

[MyOwnBundle]
  git=git@git.weboshin.ru:weboshin_cms_bundle.git
  target=/bundles/My/OwnBundle

その後、トリガーbin/vendors updateしただけで終わりです!

しかし、今はdepsファイルがなく、Composer ですべてを行うことになっています。ヒントを教えてください。

4

2 に答える 2

6

私は答えを見つけました。

// my_project/compose.json:
{
    "repositories": [
        {
            "type": "vcs",
            "url": "own_repository_url"
        }
    ],

    // ...

    "require": {
        // ...
        "own/bundle": "dev-master"
    }
},

 

// own_repository/own_bundle/compose.json:
{
    "name": "own/bundle"
}
于 2012-08-23T01:14:59.370 に答える
5

composer.json ファイルをバンドルに追加します。たとえば、バンドルの 1 つにこれがあります。

{
    "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"
}

次に、バンドルをpackagist.orgに追加します。それは非常に簡単です。基本的には、git アドレスを指定するだけで、あとは自動で実行されます。

バンドルが packagist で利用可能になったら、symfony プロジェクトの composer.json ファイルに依存関係として追加します。私の場合、私は持っています:

"require": {
    ....
    "cg/kint-bundle": "*"
},

次に、symfony ディレクトリで「composer update」を実行するだけです。autoload ファイルを更新する必要さえありません。composer が更新してくれます。あとは appkernel.php にバンドルをロードするだけです

于 2012-08-22T16:03:20.530 に答える