It should work. Just be sure to run sail artisan instead of php artisan
Basic setup with docker issues
Hi! I'm a noob with docker :) So please have understanding! I'm on MacOS.
I'm running MySQL with PHP8.2.
I have set it up using laravel sail & breeze, works fine... however issues with database env variables, as either it works in browser or it works in artisan (macos terminal, not using docker terminal)
#This works for artisan migrate, but localhost says connection refused
#DB_HOST=0.0.0.0
#This works for localhost, but artisan says getaddrinfo for host.docker.internal failed
#DB_HOST=host.docker.internal
#Artisan No such file or directory, localhost not working
#DB_HOST=localhost
#Container_name:db works for localhost, artisan says getaddrinfo for db failed:
DB_HOST=db
So I would want to make it work both in localhost browser but also use php artisan using macos terminal, is that even possible?
Did you install Laravel Sail correctly? If you used brew install sail then you installed a CLI tool for Wordpress and not Laravel Sail.
If you installed your Laravel app using the Getting Started On macOS section, then it will have installed and configured Laravel Sail for you, and you can access sail via ./vendor/bin/sail, as shown in the documentation.
I know installing Laravel via the installers ships with Laravel Sail as a dev dependency, but I don't think it's installed by default. To install it, follow the directions found in Installing Sail Into Existing Applications, that would be.
php artisan sail:install
To publish Laravel Sail's docker-compose.yml file. And then you can use ./vendor/bin/sail to access Sail.
If you ever see any user just use sail to access Laravel Sail, then they've Configures A Shell Alias for it, which the documentation also covers.
alias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
With this alias in your ~/.zshrc or ~/.bashrc or ~/.bash_profile, depending on which shell ever you normally use. You can now use sail instead of ./vendor/bin/sail.
If you're using a command called sail already, then name your alias something else. 🙂
Please or to participate in this conversation.