What is alias là gì scriscript
Version Show
Laravel Sail
IntroductionLaravel 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. At its heart, Sail is the Laravel Sail is supported on macOS, Linux, and Windows (via WSL2). Installation & SetupLaravel 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 for your operating system. During installation, you will be asked to choose which Sail supported services your application will be interacting with. Installing Sail Into Existing ApplicationsIf 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:
After Sail has been installed, you may run the
Finally, you may start Sail. To continue learning how to use Sail, please continue reading the remainder of this documentation:
Using DevcontainersIf you would like to develop within a Devcontainer, you may provide the
Configuring A Shell AliasBy default, Sail commands are invoked using the
However,
instead of repeatedly typing
To make sure this is always available, you may add this to your shell configuration file in your home directory, such as Once the shell alias has been configured, you may execute Sail commands by simply typing
Starting & Stopping SailLaravel Sail's 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
To start all of the Docker containers in the background, you may start Sail in "detached" mode:
Once the application's containers have been started, you may access the project in your web browser at: http://localhost. 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
Executing CommandsWhen 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. 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:
Executing PHP CommandsPHP commands may be executed using the
Executing Composer CommandsComposer commands may be executed using the
Installing Composer Dependencies For Existing ApplicationsIf 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. 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:
When using the Executing Artisan CommandsLaravel Artisan commands may be executed using the
Executing Node / NPM CommandsNode commands may be executed using the
If you wish, you may use Yarn instead of NPM:
Interacting With DatabasesMySQLAs you may have noticed, your application's In addition, the first time the
MySQL container starts, it will create two databases for you. The first database is named using the value of your Once you have started your containers, you may connect to the MySQL instance within your application by setting your To connect to your application's MySQL database from your local machine, you may use a graphical database management application such as TablePlus. By default, the MySQL database is accessible at RedisYour application's To connect to your application's Redis database from your local machine, you may use a graphical database management
application such as TablePlus. By default, the Redis database is accessible at MeiliSearchIf you chose to install the MeiliSearch service when installing Sail, your application's From your local machine, you may access MeiliSearch's web based administration panel by navigating to File StorageIf you plan to use Amazon S3 to store files while running your application in its
production environment, you may wish to install the MinIO service when installing Sail. MinIO provides an S3 compatible API that you may use to develop locally using Laravel's By default, your application's
In order for Laravel's Flysystem
integration to generate proper URLs when using MinIO, you should define the
You may create buckets via the MinIO console, which is available at
Running TestsLaravel provides amazing testing support out of the box, and you may use Sail's
The Sail
By default, Sail will
create a dedicated
Laravel DuskLaravel 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
Next, ensure that the
Finally, you may run your Dusk test suite by starting Sail and running the
Selenium On Apple SiliconIf your local machine contains an Apple Silicon chip, your
Previewing EmailsLaravel Sail's default
When Sail is running, you may access the MailHog web interface at: http://localhost:8025 Container CLISometimes you may wish to start a Bash session within your application's container. You may use the
To start a new
Laravel Tinker session, you may execute the
PHP VersionsSail 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
In addition,
you may wish to update your
After updating your application's
Node VersionsSail installs Node 16 by default. To change the Node version that is installed when building your images, you may update the
After updating your application's
Sharing Your SiteSometimes 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
When
sharing your site via the
If you would like to choose the subdomain for your shared site, you may provide the
Debugging With XdebugLaravel Sail's Docker configuration includes support for Xdebug, a popular and powerful debugger for PHP. In order to enable Xdebug, you will need to add a few variables to your
application's
Linux Host IP ConfigurationInternally, the First, you should determine the correct host IP address to add to the environment variable by running the following command. Typically, the
Once you have obtained the correct host IP address, you should define the
Xdebug CLI UsageA
Xdebug Browser UsageTo debug your application while interacting with the application via a web browser, follow the instructions provided by Xdebug for initiating an Xdebug session from the web browser. If you're using PhpStorm, please review JetBrain's documentation regarding zero-configuration debugging.
CustomizationSince Sail is just Docker, you are free to customize nearly everything about it. To publish Sail's own Dockerfiles, you may execute the
After running this command, the Dockerfiles and other configuration files used by Laravel Sail will be placed within a |