セットアップ | Symfony7
対象: Symfony 7.4 LTS(PHP 8.2 以上)。最新のサポート状況は Symfony Releases で確認してください。
資料
フロー
1. Symfony CLI をインストール
$ curl -sS https://get.symfony.com/cli/installer | bash
$ symfony version
Symfony CLI version x.y.z
ref. Download Symfony
2. 要件を確認
$ symfony check:requirements
Symfony Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> PHP is using the following php.ini file:
/path/to/php.ini
> Checking Symfony requirements:
.............................
[OK]
Your system is ready to run Symfony projects
Note The command console can use a different php.ini file
~~~~ than the one used by your web server.
Please check that both the console and the web server
are using the same PHP version and configuration.
3. コンソールアプリケーションを作成
Composer を使う方法と Symfony CLI(symfony binary)を使う方法があります。どちらも同じ骨組み(symfony/skeleton)が作成されます。
ref. Creating Symfony Applications
3.1 Composer を更新
sudo は使わず、通常のユーザーで実行します(root で実行すると Composer が警告します)。
composer self-update
3.2 アプリケーションを作成
Composer を使う場合
composer create-project symfony/skeleton:"7.4.*" sample
Symfony CLI を使う場合
symfony new sample --version="7.4.*"
Symfony CLI は、あわせて git init も実行します。Composer の場合は必要に応じて自分で git init してください。
Web アプリケーション用のパッケージ一式(Twig、Doctrine、Security など)を含めるには、Symfony CLI に --webapp を付けます。
symfony new sample --version="7.4.*" --webapp