Last week, I have received my new Macbook Pro M1. I am really amazed by its performance and battery timing. The one thing you instantly notice is that it does not heat up like the Intel-based Macbook Pro.
I won't go into the details about how I struggled to set up my local development environment with different options like Homestead, Laradoc, Sail etc.
Using a new M1 Mac the best and easy solution is to use Laravel Valet.
Following are the steps:
Setup ARM Compatibility
- Install Rosetta with the following command:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
- Add the following function to your
.zshrc
in order to make an alias forarm
while running commands with x86 flags. Shoutout to Matt Stauffer
arm() {
arch -x86_64 $@
}
Homebrew
- Run the following command to install homebrew
arm /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- You can confirm the installation with
brew --version
and you should get a result like the following:
PHP
- Run the following command to install PHP latest version
arm brew install php
- If you want to install a specific version of PHP the run the following command
arm brew install php@7.3
- You can confirm the installation with
php -v
and you should get a response like the following
MySQL
- For the latest version of MySQL run the following command
arm brew install mysql
arm brew services start mysql
- For a specific version
arm brew install mysql@5.7
arm brew services start mysql@5.7
- Setup default root password with the following command
mysql_secure_installation
- It will prompt you steps like the following image
Composer
- Install composer via the following commands and then move the PHAR file to the bin folder
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
- Add the following line to your
.zshrc
file
export PATH=${PATH}:~/.composer/vendor/bin
Valet
- To install Valet run the following command
composer global require laravel/valet
valet install
- You can confirm the Valet installation by running
valet -V
and you should get a response like the following - After successful installation, now you can either park an entire folder or link a single application folder. For more details go to Valet
Start Valet
- You can start Valet with the following command
valet start
- You should get a response like the following
- Now, you can visit any of your Laravel application that you have already linked
Some of the useful commands list
arm brew services list
arm brew services start mysql
arm brew services stop mysql
arm brew services restart mysql
valet start
valet stop
valet restart
valet install php@7.3
valet use php@7.3
Top comments (5)
Thanks so much for posting this!
How is the performance and compatibility for Laravel development? do you use Phpstorm, do you have the 8gb ram or the 16gb ram version?
So far I am satisfied with it and found no issues with Laravel development. I have 16GB RAM and use PhpStorm on daily basics.
Btw, I get the error "Installer corrupt" when attempting line 2 of the Composer section.
MOre about valet can be found at laravel.com/docs/8.x/valet