sjwmdev/laravel-sail-mysql
Laravel Sail with Docker and MySQL Server support
28
Follow these 6 steps to install WSL:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
(Ensure you meet the version and build number criteria) Update to the latest Windows version in the Settings menu if needed.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
(Choose the appropriate package based on your system type) Install the package and proceed to the next step.
wsl.exe --install
orwsl.exe --update
wsl --set-default-version 2
Visit the Microsoft Store and select your preferred Linux distribution (e.g., Ubuntu). Launch the newly installed distribution, and create a user account and password.
Install Windows Terminal for enhanced command line functionality.
Download and run Docker Desktop Installer.
Follow the installation prompts, ensuring to select the appropriate backend option. Start Docker Desktop after successful installation.
curl -s https://laravel.build/example-app | bash
cd example-app
./vendor/bin/sail up
Optionally, create a shell alias for Sail commands.
Add to your shell configuration file (e.g., ~/.zshrc or ~/.bashrc)
alias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
Restart your shell.
sail up
sail up -d
Access the project in your browser at http://localhost
sail stop
To enable graphical interaction with the database, you'll need to add the phpmyadmin
service and configure the DB_HOST
, DB_USERNAME
, and DB_PASSWORD
in your .env
file.
After updating the docker-compose.yml
file, access the phpMyAdmin interface using either of these URLs in your web browser: 127.0.0.1:8081
or localhost:8081
. You'll be prompted to enter server details, username, and password.
The login credentials depend on what's specified in your project's .env
file. On the server, use "mysql" as the username. With this setup, you're ready to kickstart your development with Laravel and PhpMyAdmin.
docker-compose.yml
file.If you encounter a RuntimeException like:
In order to use the Auth::routes() method, please install the laravel/ui package.
To resolve this issue, you'll need to install the laravel/ui package. This package provides a simple way to scaffold authentication views and routes.
You can install it using Composer with the following command:
composer require laravel/ui
If you receive a message like:
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Instead, it's best to run Composer as a regular user. If you need to install global packages, you can use the --global flag, but still without sudo.
Here's the proper way to install the laravel/ui package without using sudo:
composer require laravel/ui --dev
The --dev flag is optional and is used if you only need this package for development purposes. If you need it in production, you can omit this flag.
After installing the package, you can generate the necessary views and routes for authentication using Artisan:
php artisan ui bootstrap --auth
Replace Bootstrap with the front-end framework you're using (e.g., vue, react, etc.) if it's different.
This will generate the authentication views in your resources/views/auth directory, along with the necessary routes.
Remember to clear your config cache if you've previously cached it:
php artisan config:clear
After doing this, try running your Laravel application again.
If you're using Docker and Laravel Sail, you might need to rebuild your Docker containers to make sure the changes take effect:
sail down
sail up -d
Make sure to backup any important files or configurations before making these changes.
Happy coding! 😊
docker pull sjwmdev/laravel-sail-mysql