Setup a new project using Laravel Sail (macOS)02:33
Executing commands inside your application containers02:20
Creating a database client connection01:30
Testing emails with Mailhog02:35
Changing the php version in Laravel Sail01:29
Run Sail and Valet in parallel01:39
Customizing Laravel Sail01:25
Setup Laravel Sail for an existing Laravel application00:49
Executing commands inside your application containers
[00:00] Before executing commands inside your application container, make sure sail is up and running. (
./vendor/bin/sail up -d) This will start sail in the background. Now to stop everything you can type in
[00:23] Typing vendor bin sail every time you want to run a command is kind of annoying. Let's set up an alias for it. So we'll do
alias sail="bash vendor/bin/sail", and now instead of typing in
./vendor/bin/sail down or up, or whatever else, we can just do
sail up -d to start it in the background.
[00:57] With laravel sail we can execute various commands directly inside the application container. For example, to install a composer package you can do
sail composer require and then the name of the package, for example
sail composer require laravel/breeze --dev.
[01:24] Now if I go inside my
composer.json file, we can see we have laravel breeze installed. You can also do the same thing with npm packages. For example
sail npm install date-fns. Now if I open my
package.json file, we can see
date-fns is pulled in.
[01:47] To run the application test suit type in
sail test; and it even works with flags. For example
sail test --filter Feature - to only run the feature tests.
[02:00] Another thing you can do is start a new thinker session. You can do that with
ctrl+c to escape. And finally, to initiate a mysql terminal session, you can do