Sign inSign up

sjwmdev/laravel-sail-pgsql

By sjwmdev

Updated almost 3 years ago

Laravel Sail with Docker and PostgreSQL support

Image
Languages & frameworks
Developer tools
1

68

sjwmdev/laravel-sail-pgsql repository overview

Setting up Laravel with Docker and Sail on Windows 11

Prerequisites

Installing WSL

Follow these 6 steps to install WSL:

Step 1 - Enable WSL
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Step 3 - Check requirements for running WSL 2

(Ensure you meet the version and build number criteria) Update to the latest Windows version in the Settings menu if needed.

Step 3 - Enable Virtual Machine feature
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Step 4 - Download the Linux kernel update package

(Choose the appropriate package based on your system type) Install the package and proceed to the next step.

Step 5 - Set WSL 2 as the default version
wsl --set-default-version 2
Step 6 - Install Linux Distribution

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 (Optional)

Install Windows Terminal for enhanced command line functionality.

Installing Docker Desktop

Download and run Docker Desktop Installer.

Follow the installation prompts, ensuring to select the appropriate backend option. Start Docker Desktop after successful installation.

Install Laravel Project

Create a new Laravel project
curl -s https://laravel.build/example-app | bash
Navigate to the project directory and start Laravel Sail
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.

Starting & Stopping Sail

Start Laravel Sail
sail up
Start in detached mode
sail up -d

Access the project in your browser at http://localhost

Stop all containers
sail stop

Important Notes

  • To change the database service, edit the docker-compose.yml file.
  • Install PhpMyAdmin for MySQL or PgAdmin 4 for pgsql for graphical database interaction.

Troubleshooting Notes

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.

Tag summary

Content type

Image

Digest

sha256:71d009663

Size

457.5 MB

Last updated

almost 3 years ago

docker pull sjwmdev/laravel-sail-pgsql:lsp-1