Readouble

Laravel 8.x Laravel Sail

イントロダクションIntroduction

Laravel Sailは、LaravelのデフォルトのDocker開発環境を操作するための軽量コマンドラインインターフェイスです。 Sailは、Dockerの経験がなくても、PHP、MySQL、Redisを使用してLaravelアプリケーションを構築するための優れた出発点を提供します。Laravel Sail[https://github.com/laravel/sail] is a light-weight command-line interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience.

Sailの本質は、docker-compose.ymlファイルとプロジェクトのルートに保存されているsailスクリプトです。sailスクリプトは、docker-compose.ymlファイルで定義されたDockerコンテナを操作するための便利なメソッドをCLIで提供します。At its heart, Sail is the docker-compose.yml file and the sail script that is stored at the root of your project. The sail script provides a CLI with convenient methods for interacting with the Docker containers defined by the docker-compose.yml file.

Laravel Sailは、macOS、Linux、Windows(WSL2を使用)に対応しています。Laravel Sail is supported on macOS, Linux, and Windows (via WSL2[https://docs.microsoft.com/en-us/windows/wsl/about]).

インストールと準備Installation & Setup

Laravel Sailはいつも、新しいLaravelアプリケーションとともに自動的にインストールされるため、すぐ使用を開始できます。新しいLaravelアプリケーションを作成する方法については、使用しているオペレーティングシステム用のLaravelインストールドキュメントを参照してください。インストール時には、アプリケーションで操作するSailサポートサービスを選択するよう求められます。Laravel Sail is automatically installed with all new Laravel applications so you may start using it immediately. To learn how to create a new Laravel application, please consult Laravel's installation documentation[/docs/{{version}}/installation] for your operating system. During installation, you will be asked to choose which Sail supported services your application will be interacting with.

既存アプリケーションへのSailインストールInstalling Sail Into Existing Applications

既存のLaravelアプリケーションでSailを使うことに興味を持っている場合は、Composerパッケージマネージャを使用してSailをインストールできます。もちろん、以降の手順は、既存のローカル開発環境で、Composerの依存関係をインストールできると仮定しています。If you are interested in using Sail with an existing Laravel application, you may simply install Sail using the Composer package manager. Of course, these steps assume that your existing local development environment allows you to install Composer dependencies:

composer require laravel/sail --dev

Sailをインストールした後は、sail:install Artisanコマンドを実行してください。このコマンドは、Sailのdocker-compose.ymlファイルをアプリケーションのルートへリソース公開します。After Sail has been installed, you may run the sail:install Artisan command. This command will publish Sail's docker-compose.yml file to the root of your application:

php artisan sail:install

最後に、Sailを立ち上げましょう。Sailの使い方を学び続けるには、このドキュメントの残りを続けてお読みください。Finally, you may start Sail. To continue learning how to use Sail, please continue reading the remainder of this documentation:

./vendor/bin/sail up

Devcontainerの使用Using Devcontainers

もし、Devcontainer内で開発したい場合は、--devcontainerオプションをsail:installコマンドで指定してください。--devcontainerオプションは、sail:installコマンドに、デフォルトの.devcontainer/devcontainer.jsonファイルをアプリケーションのルートにリソース公開するように指示します。If you would like to develop within a Devcontainer[https://code.visualstudio.com/docs/remote/containers], you may provide the --devcontainer option to the sail:install command. The --devcontainer option will instruct the sail:install command to publish a default .devcontainer/devcontainer.json file to the root of your application:

php artisan sail:install --devcontainer

Bashエイリアスの設定Configuring A Bash Alias

デフォルトでSailコマンドは、すべての新しいLaravelアプリケーションに含まれているvendor/bin/sailスクリプトを使用して起動します。By default, Sail commands are invoked using the vendor/bin/sail script that is included with all new Laravel applications:

./vendor/bin/sail up

vendor/bin/sailを実行するため繰り返し入力する代わりに、Sailコマンドをより簡単に実行できるようにするBashエイリアスを設定することをおすすめします。However, instead of repeatedly typing vendor/bin/sail to execute Sail commands, you may wish to configure a Bash alias that allows you to execute Sail's commands more easily:

alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'

Bashエイリアスを設定したら、sailと入力するだけでSailコマンドを実行できます。このドキュメントの残りの部分の例は、このエイリアスが設定済みであることを前提としています。Once the Bash alias has been configured, you may execute Sail commands by simply typing sail. The remainder of this documentation's examples will assume that you have configured this alias:

sail up

Sailの開始と停止Starting & Stopping Sail

Laravel Sailのdocker-compose.ymlファイルは、Laravelアプリケーションの構築を支援するために連携するさまざまなDockerコンテナーを定義します。これらの各コンテナーは、docker-compose.ymlファイルのservices設定内のエントリです。laravel.testコンテナは、アプリケーションを提供するメインのアプリケーションコンテナです。Laravel Sail's docker-compose.yml file defines a variety of Docker containers that work together to help you build Laravel applications. Each of these containers is an entry within the services configuration of your docker-compose.yml file. The laravel.test container is the primary application container that will be serving your application.

Sailを開始する前に、ローカルコンピューターで他のWebサーバまたはデータベースが実行されていないことを確認する必要があります。アプリケーションのdocker-compose.ymlファイルで定義されているすべてのDockerコンテナーを起動するには、upコマンドを実行する必要があります。Before starting Sail, you should ensure that no other web servers or databases are running on your local computer. To start all of the Docker containers defined in your application's docker-compose.yml file, you should execute the up command:

sail up

すべてのDockerコンテナをバックグラウンドで起動するには、Sailを「デタッチdetached)」モードで起動します。To start all of the Docker containers in the background, you may start Sail in "detached" mode:

sail up -d

アプリケーションのコンテナが開始されると、Webブラウザ(http:// localhost)でプロジェクトにアクセスできます。Once the application's containers have been started, you may access the project in your web browser at: http://localhost[http://localhost].

すべてのコンテナを停止するには、Control Cを押してコンテナの実行を停止します。または、コンテナがバックグラウンドで実行されている場合は、stopコマンドを使用します。To stop all of the containers, you may simply press Control C to stop the container's execution. Or, if the containers are running in the background, you may use the stop command:

sail stop

コマンドの実行Executing Commands

Laravel Sailを使用する場合、アプリケーションはDockerコンテナー内で実行され、ローカルコンピューターから分離されます。さらにSailは、任意のPHPコマンド、Artisanコマンド、Composerコマンド、Node / NPMコマンドなど、アプリケーションに対してさまざまなコマンドを実行するための便利な方法も提供します。When using Laravel Sail, your application is executing within a Docker container and is isolated from your local computer. However, Sail provides a convenient way to run various commands against your application such as arbitrary PHP commands, Artisan commands, Composer commands, and Node / NPM commands.

**Laravelのドキュメントを読むと、Sailを参照しないComposer、Artisan、Node/NPMコマンドの参照をよく目にするでしょう。**こうした実行例は、これらのツールがローカルコンピューターにインストールされていることを前提としています。ローカルのLaravel開発環境にSailを使用している場合は、Sailを使用してこれらのコマンドを実行する必要があります。When reading the Laravel documentation, you will often see references to Composer, Artisan, and Node / NPM commands that do not reference Sail. Those examples assume that these tools are installed on your local computer. If you are using Sail for your local Laravel development environment, you should execute those commands using Sail:

# Artisanコマンドをローカル環境で実行
php artisan queue:work

# Laravel Sailの中でArtisanコマンドを実行
sail artisan queue:work

PHPコマンドの実行Executing PHP Commands

PHPコマンドは、phpコマンドを使用して実行します。もちろん、これらのコマンドは、アプリケーション用に構成されたPHPバージョンを使用して実行されます。Laravel Sailで利用可能なPHPバージョンの詳細については、PHPバージョンのドキュメントを参照してください。PHP commands may be executed using the php command. Of course, these commands will execute using the PHP version that is configured for your application. To learn more about the PHP versions available to Laravel Sail, consult the PHP version documentation[#sail-php-versions]:

sail php --version

sail php script.php

Composerコマンドの実行Executing Composer Commands

Composerコマンドは、composerコマンドを使用して実行します。 Laravel Sailのアプリケーションコンテナには、Composer2.xがインストール済みです。Composer commands may be executed using the composer command. Laravel Sail's application container includes a Composer 2.x installation:

sail composer require laravel/sanctum

既存アプリケーションでComposer依存関係のインストールInstalling Composer Dependencies For Existing Applications

チームでアプリケーションを開発している場合、最初にLaravelアプリケーションを作成するのは自分ではないかもしれません。そのため、アプリケーションのリポジトリをローカルコンピュータにクローンした後、Sailを含むアプリケーションのComposer依存関係は一切インストールされていません。If you are developing an application with a team, you may not be the one that initially creates the Laravel application. Therefore, none of the application's Composer dependencies, including Sail, will be installed after you clone the application's repository to your local computer.

アプリケーションの依存関係をインストールするには、アプリケーションのディレクトリに移動し、次のコマンドを実行します。このコマンドは、PHPとComposerを含む小さなDockerコンテナを使用して、アプリケーションの依存関係をインストールします。You may install the application's dependencies by navigating to the application's directory and executing the following command. This command uses a small Docker container containing PHP and Composer to install the application's dependencies:

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

laravelsail/phpXX-composerイメージを使用する場合、アプリケーションで使用する予定のPHPと同じバージョン(748081)を使用する必要があります。When using the laravelsail/phpXX-composer image, you should use the same version of PHP that you plan to use for your application (74, 80, or 81).

Artisanコマンドの実行Executing Artisan Commands

Laravel Artisanコマンドは、artisanコマンドを使用して実行します。Laravel Artisan commands may be executed using the artisan command:

sail artisan queue:work

Node/NPMコマンドの実行Executing Node / NPM Commands

Nodeコマンドはnpmコマンドを使用して実行し、NPMコマンドはnpmコマンドを使用して実行します。Node commands may be executed using the node command while NPM commands may be executed using the npm command:

sail node --version

sail npm run prod

ご希望であれば、NPMの代わりにYarnを使用できます。If you wish, you may use Yarn instead of NPM:

sail yarn

データベース操作Interacting With Databases

MySQLMySQL

お気づきかもしれませんが、アプリケーションのdocker-compose.ymlファイルには、MySQLコンテナのエントリが含まれています。このコンテナはDockerボリュームを使用しているため、コンテナを停止して再起動しても、データベースに保存されているデータは保持されます。また、MySQLコンテナの起動時に、名前がDB_DATABASE環境変数の値と一致するデータベースが存在することを確認します。As you may have noticed, your application's docker-compose.yml file contains an entry for a MySQL container. This container uses a Docker volume[https://docs.docker.com/storage/volumes/] so that the data stored in your database is persisted even when stopping and restarting your containers. In addition, when the MySQL container is starting, it will ensure a database exists whose name matches the value of your DB_DATABASE environment variable.

コンテナを起動したら、アプリケーションの.envファイル内のDB_HOST環境変数をmysqlに設定することで、アプリケーション内のMySQLインスタンスに接続できます。Once you have started your containers, you may connect to the MySQL instance within your application by setting your DB_HOST environment variable within your application's .env file to mysql.

ローカルマシンからアプリケーションのMySQLデータベースに接続するには、TablePlusなどのグラフィカルデータベース管理アプリケーションを使用できます。デフォルトでMySQLデータベースは、localhostのポート3306からアクセスできます。To connect to your application's MySQL database from your local machine, you may use a graphical database management application such as TablePlus[https://tableplus.com]. By default, the MySQL database is accessible at localhost port 3306.

RedisRedis

アプリケーションのdocker-compose.ymlファイルには、Redisコンテナーのエントリも含まれています。このコンテナはDockerボリュームを使用しているため、コンテナを停止して再起動しても、Redisデータに保存されているデータは保持されます。コンテナを起動したら、アプリケーションの.envファイル内のREDIS_HOST環境変数をredisに設定することで、アプリケーション内のRedisインスタンスに接続できます。Your application's docker-compose.yml file also contains an entry for a Redis[https://redis.io] container. This container uses a Docker volume[https://docs.docker.com/storage/volumes/] so that the data stored in your Redis data is persisted even when stopping and restarting your containers. Once you have started your containers, you may connect to the Redis instance within your application by setting your REDIS_HOST environment variable within your application's .env file to redis.

ローカルマシンからアプリケーションのRedisデータベースに接続するには、TablePlusなどのグラフィカルデータベース管理アプリケーションを使用できます。デフォルトでは、Redisデータベースはlocalhostのポート6379でアクセスできます。To connect to your application's Redis database from your local machine, you may use a graphical database management application such as TablePlus[https://tableplus.com]. By default, the Redis database is accessible at localhost port 6379.

MeiliSearchMeiliSearch

Sailのインストール時にMeiliSearchサービスのインストールを選択した場合、アプリケーションのdocker-compose.ymlファイルには、Laravel Scoutコンパチブルである、この強力な検索エンジンのエントリが含まれます。コンテナを起動したら、環境変数MEILISEARCH_HOSThttp://meilisearch:7700を設定すると、アプリケーション内のMeiliSearchインスタンスに接続できます。If you chose to install the MeiliSearch[https://www.meilisearch.com] service when installing Sail, your application's docker-compose.yml file will contain an entry for this powerful search-engine that is compatible[https://github.com/meilisearch/meilisearch-laravel-scout] with Laravel Scout[/docs/{{version}}/scout]. Once you have started your containers, you may connect to the MeiliSearch instance within your application by setting your MEILISEARCH_HOST environment variable to http://meilisearch:7700.

ローカルマシンから、Webブラウザのhttp://localhost:7700に移動して、MeiliSearchのWebベース管理パネルへアクセスできます。From your local machine, you may access MeiliSearch's web based administration panel by navigating to http://localhost:7700 in your web browser.

ファイルストレージFile Storage

本番環境でアプリケーションを実行する際に、Amazon S3を使用してファイルを保存する予定であれば、Sailをインストールする際にMinIOサービスをインストールするとよいでしょう。MinIOはS3互換のAPIを提供しており、本番のS3環境で「テスト」ストレージバケットを作成せずに、Laravelのs3ファイルストレージドライバーを使ってローカルに開発するために使用できます。Sailのインストール時にMinIOのインストールを選択すると、アプリケーションのdocker-compose.ymlファイルにMinIOの設定セクションが追加されます。If you plan to use Amazon S3 to store files while running your application in its production environment, you may wish to install the MinIO[https://min.io] service when installing Sail. MinIO provides an S3 compatible API that you may use to develop locally using Laravel's s3 file storage driver without creating "test" storage buckets in your production S3 environment. If you choose to install MinIO while installing Sail, a MinIO configuration section will be added to your application's docker-compose.yml file.

アプリケーションのデフォルトfilesystems設定ファイルには、s3ディスクのディスク設定がすでに含まれています。このディスクを使ってAmazon S3と連携するだけでなく、その構成を制御する関連環境変数を変更するだけで、MinIOなどのS3互換のファイルストレージサービスと連携することができます。例えば、MinIOを使用する場合、ファイルシステムの環境変数の設定は次のように定義します。By default, your application's filesystems configuration file already contains a disk configuration for the s3 disk. In addition to using this disk to interact with Amazon S3, you may use it to interact with any S3 compatible file storage service such as MinIO by simply modifying the associated environment variables that control its configuration. For example, when using MinIO, your filesystem environment variable configuration should be defined as follows:

FILESYSTEM_DRIVER=s3
AWS_ACCESS_KEY_ID=sail
AWS_SECRET_ACCESS_KEY=password
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=local
AWS_ENDPOINT=http://minio:9000
AWS_USE_PATH_STYLE_ENDPOINT=true

テスト実行Running Tests

Laravelは、はじめからすばらしいテストサポートを提供しています。Sailのtestコマンドを使用してアプリケーションの機能と単体テストを実行できます。PHPUnitで指定できるCLIオプションはすべて、testコマンドに渡せます。Laravel provides amazing testing support out of the box, and you may use Sail's test command to run your applications feature and unit tests[/docs/{{version}}/testing]. Any CLI options that are accepted by PHPUnit may also be passed to the test command:

sail test

sail test --group orders

Sailのtestコマンドは、test Artisanコマンドを実行するのと同じです。The Sail test command is equivalent to running the test Artisan command:

sail artisan test

Laravel DuskLaravel Dusk

Laravel Duskは、表現力豊かで使いやすいブラウザ自動化およびテストのAPIを提供します。Sailのおかげで、Seleniumやその他のツールをローカルコンピューターにインストールしなくても、これらのテストを実行できます。使い始めるには、アプリケーションのdocker-compose.ymlファイルでSeleniumサービスのコメントを解除します。Laravel Dusk[/docs/{{version}}/dusk] provides an expressive, easy-to-use browser automation and testing API. Thanks to Sail, you may run these tests without ever installing Selenium or other tools on your local computer. To get started, uncomment the Selenium service in your application's docker-compose.yml file:

selenium:
    image: 'selenium/standalone-chrome'
    volumes:
        - '/dev/shm:/dev/shm'
    networks:
        - sail

次に、アプリケーションのdocker-compose.ymlファイルのlaravel.testサービスにseleniumdepends_onエントリがあることを確認します。Next, ensure that the laravel.test service in your application's docker-compose.yml file has a depends_on entry for selenium:

depends_on:
    - mysql
    - redis
    - selenium

最後に、Sailを起動してduskコマンドを実行することにより、Duskテストスイートを実行できます。Finally, you may run your Dusk test suite by starting Sail and running the dusk command:

sail dusk

Apple Silicon上のSeleniumSelenium On Apple Silicon

ローカルマシンに Apple Silicon チップが搭載されている場合、seleniumサービスにはseleniarm/standalone-chromiumイメージを使用する必要があります。If your local machine contains an Apple Silicon chip, your selenium service must use the seleniarm/standalone-chromium image:

selenium:
    image: 'seleniarm/standalone-chromium'
    volumes:
        - '/dev/shm:/dev/shm'
    networks:
        - sail

メールのプレビューPreviewing Emails

LaravelSailのデフォルトの docker-compose.ymlファイルには、MailHogのサービスエントリが含まれています。MailHogは、ローカル開発中にアプリケーションから送信された電子メールをインターセプトし、ブラウザで電子メールメッセージをプレビューできる便利なWebインターフェイスを提供します。Sailを使う場合、MailHogのデフォルトホストはmailhogで、ポートは1025です。Laravel Sail's default docker-compose.yml file contains a service entry for MailHog[https://github.com/mailhog/MailHog]. MailHog intercepts emails sent by your application during local development and provides a convenient web interface so that you can preview your email messages in your browser. When using Sail, MailHog's default host is mailhog and is available via port 1025:

MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_ENCRYPTION=null

Sailの実行中に、http://localhost:8025でMailHog Webインターフェイスにアクセスできます。When Sail is running, you may access the MailHog web interface at: http://localhost:8025[http://localhost:8025]

コンテナCLIContainer CLI

アプリケーションのコンテナ内でBashセッションを開始したい場合があるでしょう。shellコマンドを使用してアプリケーションのコンテナに接続し、ファイルとインストールされているサービスを検査したり、コンテナ内で任意のシェルコマンドを実行したりできます。Sometimes you may wish to start a Bash session within your application's container. You may use the shell command to connect to your application's container, allowing you to inspect its files and installed services as well execute arbitrary shell commands within the container:

sail shell

sail root-shell

新しいLaravelTinkerセッションを開始するには、tinkerコマンドを実行します。To start a new Laravel Tinker[https://github.com/laravel/tinker] session, you may execute the tinker command:

sail tinker

PHPバージョンPHP Versions

Sailは現在、PHP8.1、PHP8.0、PHP7.4を利用したアプリケーションの実行をサポートしています。SailのデフォルトPHPバージョンは8.1です。アプリケーションの実行に使用するPHPバージョンを変更するには、アプリケーションのdocker-compose.ymlファイル内のlaravel.testコンテナーのbuild定義を更新してください。Sail currently supports serving your application via PHP 8.1, PHP 8.0, or PHP 7.4. The default PHP version used by Sail is currently PHP 8.1. To change the PHP version that is used to serve your application, you should update the build definition of the laravel.test container in your application's docker-compose.yml file:

# PHP 8.1
context: ./vendor/laravel/sail/runtimes/8.1

# PHP8.0
context: ./vendor/laravel/sail/runtimes/8.0

# PHP7.4
context: ./vendor/laravel/sail/runtimes/7.4

さらに、アプリケーションで使用するPHPのバージョンを反映するために、image名を更新することもできます。このオプションも、アプリケーションのdocker-compose.ymlファイルで定義されています。In addition, you may wish to update your image name to reflect the version of PHP being used by your application. This option is also defined in your application's docker-compose.yml file:

image: sail-8.1/app

After updating your application's docker-compose.yml file, you should rebuild your container images:After updating your application's docker-compose.yml file, you should rebuild your container images:

sail build --no-cache

sail up

NodeバージョンNode Versions

SailはデフォルトでNode16をインストールします。イメージをビルドする際にインストールするNodeバージョンを変更するには、アプリケーションのdocker-compose.ymlファイル中の、laravel.testサービスのbuild.args定義を変更してください。Sail installs Node 16 by default. To change the Node version that is installed when building your images, you may update the build.args definition of the laravel.test service in your application's docker-compose.yml file:

build:
    args:
        WWWGROUP: '${WWWGROUP}'
        NODE_VERSION: '14'

アプリケーションのdocker-compose.ymlファイルを更新した後、コンテナイメージを再構築する必要があります。After updating your application's docker-compose.yml file, you should rebuild your container images:

sail build --no-cache

sail up

サイトの共有Sharing Your Site

同僚のためにサイトをプレビューしたり、アプリケーションとのWebhook統合をテストしたりするために、サイトを公開して共有する必要がある場合があります。サイトを共有するには、 shareコマンドを使用します。このコマンドを実行すると、アプリケーションへのアクセスに使用するランダムなlaravel-sail.site URLが発行されます。Sometimes you may need to share your site publicly in order to preview your site for a colleague or to test webhook integrations with your application. To share your site, you may use the share command. After executing this command, you will be issued a random laravel-sail.site URL that you may use to access your application:

sail share

shareコマンドでサイトを共有するときは、TrustProxiesミドルウェア内でアプリケーションの信頼できるプロキシを設定する必要があります。これを行わないと、urlrouteなどのURL生成ヘルパは、URL生成時に使用するべき正しいHTTPホストを決定できません。When sharing your site via the share command, you should configure your application's trusted proxies within the TrustProxies middleware. Otherwise, URL generation helpers such as url and route will be unable to determine the correct HTTP host that should be used during URL generation:

/**
 * アプリケーションで信頼するプロキシ
 *
 * @var array|string|null
 */
protected $proxies = '*';

共有サイトでサブドメインを選択する場合は、shareコマンドを実行するときにsubdomainオプションを指定します。If you would like to choose the subdomain for your shared site, you may provide the subdomain option when executing the share command:

sail share --subdomain=my-sail-site

lightbulb">Tip!! shareコマンドは、BeyondCodeによるオープンソースのトンネリングサービスであるExposeにより提供しています。{tip} The share command is powered by Expose[https://github.com/beyondcode/expose], an open source tunneling service by BeyondCode[https://beyondco.de].

XdebugによるデバッグDebugging With Xdebug

LaravelSailのDockerの設定には、PHP用の人気で強力なデバッガであるXdebugをサポートしています。XDebugを有効にするには、Xdebugを設定するために、アプリケーションの.envファイルに変数を追加する必要があります。XDebugを有効にするには、Sailを開始する前に適切なモードを設定する必要があります。Laravel Sail's Docker configuration includes support for Xdebug[https://xdebug.org/], a popular and powerful debugger for PHP. In order to enable Xdebug, you will need to add a few variables to your application's .env file to configure Xdebug[https://xdebug.org/docs/step_debug#mode]. To enable Xdebug you must set the appropriate mode(s) before starting Sail:

SAIL_XDEBUG_MODE=develop,debug

LinuxホストIP設定Linux Host IP Configuration

内部的には、XDEBUG_CONFIG環境変数はclient_host=host.docker.internalとして定義しているため、XdebugはMacとWindows(WSL2)用に正しく設定します。ローカルマシンがLinuxを実行している場合は、この環境変数を手動で定義する必要があります。Internally, the XDEBUG_CONFIG environment variable is defined as client_host=host.docker.internal so that Xdebug will be properly configured for Mac and Windows (WSL2). If your local machine is running Linux, you will need to manually define this environment variable.

まず、以下のコマンドを実行して、環境変数に追加する正しいホストIPアドレスを決定します。通常、<container-name>は、アプリケーションを提供するコンテナの名前であるべきで、多くの場合、_laravel.test_1で終わります。First, you should determine the correct host IP address to add to the environment variable by running the following command. Typically, the <container-name> should be the name of the container that serves your application and often ends with _laravel.test_1:

docker inspect -f {{range.NetworkSettings.Networks}}{{.Gateway}}{{end}} <container-name>

正しいホストIPアドレスを取得したら、アプリケーションの.envファイル内でSAIL_XDEBUG_CONFIG変数を定義する必要があります。Once you have obtained the correct host IP address, you should define the SAIL_XDEBUG_CONFIG variable within your application's .env file:

SAIL_XDEBUG_CONFIG="client_host=<host-ip-address>"

Xdebug CLI使用法Xdebug CLI Usage

Artisanのコマンドを実行する際に、sail debugコマンドを使ってデバッグセッションを開始することができます。A sail debug command may be used to start a debugging session when running an Artisan command:

# Xdebugなしでartisanコマンドを実行
sail artisan migrate

# Xdebugでartisanコマンドを実行
sail debug migrate

Xdebug ブラウザ使用法Xdebug Browser Usage

Webブラウザでアプリケーションを操作しながらデバッグするには、WebブラウザからXdebugセッションを開始するためのXdebugが提供する手順に従ってください。To debug your application while interacting with the application via a web browser, follow the instructions provided by Xdebug[https://xdebug.org/docs/step_debug#web-application] for initiating an Xdebug session from the web browser.

PhpStormを使用している場合は、[設定なしのデバッグ]](https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html)に関するJetBrainのドキュメントを確認してくださいIf you're using PhpStorm, please review JetBrain's documentation regarding zero-configuration debugging[https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html].

Note: note Laravel Sailはアプリケーション提供をartisan serveに依存しています。artisan serveコマンドは、Laravelバージョン8.53.0以降では、XDEBUG_CONFIGXDEBUG_MODE変数のみを受け付けます。古いバージョンのLaravel(8.52.0以下)では、これらの変数をサポートしていないため、デバッグ接続を受け付けません。{note} Laravel Sail relies on artisan serve to serve your application. The artisan serve command only accepts the XDEBUG_CONFIG and XDEBUG_MODE variables as of Laravel version 8.53.0. Older versions of Laravel (8.52.0 and below) do not support these variables and will not accept debug connections.

SailカスタマイズCustomization

Sailは単なるDockerであるため、Sailに関するほぼすべてを自由にカスタマイズできます。Sail独自のDockerfileをリソース公開するには、sail:publishコマンドを実行します。Since Sail is just Docker, you are free to customize nearly everything about it. To publish Sail's own Dockerfiles, you may execute the sail:publish command:

sail artisan sail:publish

このコマンドを実行すると、Laravel Sailが使用するDockerfileとその他の設定ファイルが、アプリケーションのルートディレクトリ内のdockerディレクトリに配置されます。Sailのインストールをカスタマイズした後、アプリケーションの docker-compose.yml ファイル内のアプリケーションコンテナのイメージ名を変更したいと思うことでしょう。それを行ったら、buildコマンドを使用してアプリケーションのコンテナを再構築してください。アプリケーション・イメージに一意な名前を割り当てることは、Sailを使用して1台のマシンで複数のLaravelアプリケーションを開発する場合に特に重要です。After running this command, the Dockerfiles and other configuration files used by Laravel Sail will be placed within a docker directory in your application's root directory. After customizing your Sail installation, you may wish to change the image name for the application container in your application's docker-compose.yml file. After doing so, rebuild your application's containers using the build command. Assigning a unique name to the application image is particularly important if you are using Sail to develop multiple Laravel applications on a single machine:

sail build --no-cache

章選択

設定

明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

Pagination和文
ペジネーション
ペギネーション
ページネーション
ページ付け
Scaffold和文
スカフォールド
スキャフォールド
型枠生成
本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作