PHPInfo / Valet - Two different PHP versions
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Title: Solving PHP Version Conflict in Laravel, Valet, and macOS Configuration
Introduction:
Your Laravel development environment on your MacBook Air (Mojave) is an essential tool for working with your applications, and it's crucial to have a clear understanding of how to manage the PHP versions. In this blog post, we will explore how to solve the issue where phpinfo() shows one version while php -v displays another. We'll troubleshoot the given scenario using Laravel, Valet, and Homebrew on your MacBook Air.
Steps to Solve the Issue:
Check the installed PHP Versions: Firstly, find out which PHP versions are available in your Mac by running
sudo bashin the Terminal. Then enter these commands one by one:bashbrew info php@7.2 brew info php@7.3Unlink and Link PHP Versions Using Homebrew Cask: If your system doesn't have any PHP installed, you can use Homebrew Cask to install the required versions. Run these commands in the Terminal:
bashbrew cask install php@7.2 brew cask unlink --force php@7.3Set Up Valet with Different PHP Versions for Specific Sites: Create a
.envfile in your project's root directory and add the following lines to it:bash# PHP 7.2 for Laravel projects VALET_PHP_VER_LARAVEL=7.2 # PHP 7.3 for specific sites (e.g., example.dev) VALET_PHP_VER_EXAMPLE=7.3 # Check the php version for Laravel and example.dev php -v --ini=/usr/local/etc/php/7.2/php.ini | grep PHP php -v --ini=/usr/local/etc/php/7.3/php-fpm.d/www.conf | grep PHPRestart the Nginx Service: To apply the changes, restart the Nginx service using
sudo brew services restart nginx. Ensure that you have the latest version installed by runningbrew updateand thenbrew upgrade nginx.Configure Your Local Server to Use the Desired PHP Version for Specific Sites: To set up your Valet server with custom PHP versions, run these commands in Terminal:
bashvalet secure valet use laravel-project@7.2 --port 8001 valet use example.dev@7.3 --port 8002Test the PHP Versions: To verify that your configuration is working, visit
http://laravel-project:8001andhttp://example.dev:8002. Usephp -v --ini=/path/to/php.ini | grep PHPto check the current PHP version for each site.
Conclusion:
By following these steps, you can successfully manage different PHP versions on your MacBook Air using Laravel, Valet, and Homebrew. This approach allows you to tailor your development environment based on project requirements while maintaining a clear understanding of your PHP setup. If you need more assistance or have questions about this topic, don't hesitate to contact the Laravel Company for support.