I was exploring Laravel Sail and noticed that TablePlus was suggested to manage Database which is Free and good. But I have an alternative, phpMyAdmin. It is easy to setup and link with our Laravel Application. In this article, I am attaching a code snippet for docker-compose.yml which will spin up a phpMyAdmin along with our Laravel Application.
Add following lines inside docker-compose.yml below all other services
myadmin:
image: 'phpmyadmin:latest'
ports:
- 8080:80
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
links:
- "mysql:db"
depends_on:
- mysql
networks:
- sail
It should look something like this:
Access http://localhost:8080 to access phpMyAdmin and enter database credentials mentioned in the .env files
Note: Feel free to change the port from 8080 to anything else that you prefer.
“links” will create an alias of “mysql” service with the name “db” which is required by phpMyAdmin.
In “networks”, “sail” network is mentioned which SHOULD BE same as “mysql” service.
“depends_on” meaning this “myadmin” service won’t start till “mysql” is up.
That’s it! Thanks for reading. Hope this was helpful.
Feel free to get in touch with me on twitter: @jigar_dhulla
Leave a comment