StofDoctrineExtensionsBundleのインストール方法

この記事はSymfony 2.2.1で動作確認をしました。

Gitのインストール

Gitをインストールします。

環境変数を編集してパスを通します。

Composerのインストール

Symfonyのプロジェクトのディレクトリに、次のURLにあるファイルをダウンロードします。

https://getcomposer.org/installer

ダウンロードしたファイルを実行する

php installer

同じフォルダーに「composer.json」「composer.phar」ファイルが作られます。

次のコマンドを実行して、バージョン情報が表示されたら、インストールは成功しました。

php composer.phar --version

StofDoctrineExtensionsBundleのインストール

「composer.json」に次の表を追加します。

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.2.*",
    …
    "stof/doctrine-extensions-bundle": "~1.1@dev",//<=追加
}

次のコマンドを実行すると、StofDoctrineExtensionsBundleがインストールされます。

php composer.phar install

「app/AppKernel.php」を編集して、次の行を追加します。

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        …
        new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),//<=追加
    );

「app/config/config.yml」を編集して、次の行を追加します。

stof_doctrine_extensions:
    orm:
        default:
            timestampable: true

「app/autoload.php」を編集します。

if (!function_exists('intl_get_error_code')) {
    require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';

    $loader->add('Stof', __DIR__.'/../vendor/bundles');//追加
    $loader->add('Gedmo', __DIR__.'/../vendor/gedmo-doctrine-extensions/lib');//追加
}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください