Laravel Valet is one of the most used tool on Mac by Laravel developers. Deploying test domains is lot way convenient than working on localhost or 127.0.0.1.
Make sure that all your libraries you are installing via brew only.
1. Brew, Composer & PHP Installation
If you don't have Brew or Composer Installed, Install it with following commands first.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install php using
brew install php@7.4
Once installed start php in background with following command. You will have to do it only once. It will start automatically after every Mac restart.
brew services start php@7.4
Install Composer
brew install composer
2. Valet Installation
composer global require laravel/valet
To use the valet command directly we shall add it to path using sudo nano /etc/paths
and adding new line at end.
~/.composer/vendor/bin
Once done, open the new terminal and run
valet install
This will configure and install Valet and DnsMasq, and register Valet's daemon to launch when your system starts. Now give necessary permissions by
cd ~/.composer/
sudo chown -R $(whoami) vendor
Once Valet is installed, try pinging any *.test
domain on your terminal using a command such as ping foobar.test
. If Valet is installed correctly you should see this domain responding on 127.0.0.1
.
Valet will automatically start its daemon each time your machine boots. There is no need to run valet start or valet install ever again once the initial Valet installation is complete.
3. Start Valet for Workspace folder
I have Sites folder in my Mac on /Users/ganesh/Sites/
where I want to store all my websites.
cd ~/Sites
valet park
Now let's create a website http://mysite.test by
mkdir mysite
touch mysite/index.html
You will start seeinng blank website.
4. Database Setup
We will be using MySql 5.7 Database.
brew install mysql@5.7
Start database in background using
brew services start mysql@5.7
Note: We've installed your MySQL database without a root
password. To secure it run mysql_secure_installation
.
Add mysql to path using sudo nano /etc/paths
.
/usr/local/opt/mysql@5.7/bin
5. Install PHPMyAdmin
brew install phpmyadmin
Setup Valet for phpmyadmin
cd /usr/local/share/phpmyadmin
valet domain test
valet link
If you will be using the PHPMyAdmin without password, you will need to enable that at
sudp nano /usr/local/etc/phpmyadmin.config.inc.php
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Leave a Reply