Adding PHPMyAdmin to Laravel Sail

Elijah Cruz
2 min readJun 17, 2021

PHPMyAdmin is very widely used, and it makes MySQL much easier.

phpMyAdmin is a free and open-source administration tool for MySQL and MariaDB. It is widely used in development because with it, you’re able to manage your databases from a simple web interface, versus using the terminal.

I have also wrote a tutorial on adding PHPMyAdmin to Homestead as well.

This tutorial assumes you’re already using Laravel Sail on your project, and that you have Docker and Docker Compose installed, as well as having “sail” as an alias.

First, we need to open our docker-compose.yml in the root of our project.

From here, we need to find the depends on: line, and add phpmyadmin in the list:

...
depends_on:
- mysql
- redis
- minio
- phpmyadmin
...

From here, we’ll go into our services, and add it as a service. We need to make sure to add sail’s network, or else we won’t be able to access our mysql.

phpmyadmin:
image: 'phpmyadmin:latest'
ports:
- 8080:80
networks:
- sail
environment:
- PMA_ARBITRARY=1

From here, we just need to run “sail up -d” and that’s it! We’ve installed PHPMyAdmin. You’ll be able to access it at localhost:8080

When you load the page, you’ll have to enter “mysql” as the server, and the username and password you have in your .env file for your project.

PHPMyAdmin Login

The reason you have to enter mysql as the server, like your Laravel’s .env file, is because that is the hostname generated for your mysql docker image. It is the equivalent of the image’s IP address, which you won’t need to know.

And there you have it! Now you can access your Laravel Sail project’s MySQL via PHPMyAdmin!

--

--