Init / requirements
xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew update
install (old / deprecated) PHP
brew install [email protected]
when you need deprecated PHP / Change Current PHP version
brew tap shivammathur/php
brew install shivammathur/php/[email protected]
# use 7.2 for default
brew link --overwrite --force shivammathur/php/[email protected]
open new CLI session
check php version
php -v
check php-fpm version
at any page
<?php
phpinfo();
?>
install (brew) PHP extension
pecl install <extension>
pecl install xdebug
# is if php 7.4; https://xdebug.org/docs/compat
pecl install xdebug-3.0.0
add config, xdebug.ini (/usr/local/etc/php/7.2/conf.d or /opt/homebrew/etc/php/7.2/conf.d)
[xdebug]
zend_extension="xdebug.so"
xdebug.mode=debug
xdebug.start_with_request=yes
brew install imagemagick
or apt-get install imagemagick
pecl install imagick
conf.d/imagick.ini
extension="imagick.so"
check is installed
php -i | grep Imagick
restart, reload php-fpm
brew services restart [email protected]
for debug, find php.ini location
php -i | grep "Loaded Configuration File"
If valet is already installed; after install or change config
valet restart
If you have change PHP version
valet stop
rm ~/.config/valet/valet.sock
valet use [email protected] --force
valet start
disable os x native Apache (important)
sudo apachectl stop
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
If not deactivated, will display…
It works!
install Composer
// it will auto install latest PHP (like 8.1)
brew install composer
// or
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
install Valet / or after valet update
composer global require laravel/valet
// auto install nginx, dnsmasq
valet install
set localhost suffix test
valet domain test
if need https; for https://my-dev.test
valet secure my-dev
valet unsecure my-dev
Valet set Nginx root
move to Project root directory
valet park
move to custom domain directory; e.g. ~/projects/cola-dev-project
valet link cola-dev
domain should be http://cola-dev.test
Valet Nginx vhost conf
use valet proxy to proxy a custom domain (nodejs project)
valet proxy --secure my.project-2.localhost http://localhost:3000
valet proxy --secure hey.project-3.localhost http://node-js.localhost:8080/
main location path
/usr/local/etc/nginx/valet
custom domain, location path and example
~/.config/valet/Nginx
~/.config/valet/Nginx/cola-dev
after change nginx conf…
valet restart
// or
sudo nginx -t
sudo nginx -s reload
Nginx conf / CORS conf
modify /usr/local/etc/nginx/valet/valet.conf
(or /opt/homebrew/etc/nginx/valet/valet.conf)
## add CORS header for easier test
add_header 'Access-Control-Allow-Origin' * always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, OPTIONS, PATCH, DELETE' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;