How to Set Up a Laravel Environment with PHP 7.4
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
This article explains how to set up a Laravel environment specifying PHP 7.4 as the version.
Install PHP 7.4
We will use Homebrew for this installation. The Homebrew installation process is simple:
You can install it easily by running the command provided on the Homebrew official page.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"brew -vIf the installation is successful, you can check the version.
Install PHP 7.4
brew install [email protected]Set Up the Path
For macOS Catalina or later using zsh:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrcFor older macOS versions using bash:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profileThis will set up the path correctly.
Start PHP 7.4
brew services start [email protected]Restart the Terminal (Easy to Forget)
php -vIf the PHP version is displayed, the setup is complete.
Install Composer
Run the commands from the official site in order:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
php composer-setup.php
php -r "unlink('composer-setup.php');"After running these commands, a composer.phar file will be created in your current terminal directory. You need to move it to a specific location to make it executable. Use the following command:
sudomeans executing the command as an administrator.mvstands for "move."- This command moves
composer.pharto/usr/local/bin/composer.
sudo mv composer.phar /usr/local/bin/composerYou will be prompted for your computer's login password.
Install Laravel
The latest version of Laravel may not support PHP 7.4, so you may need to install an older version.
composer create-project laravel/laravel:^6.0 . example-app
cd example-app
php artisan serveFor more details, including images, check out this article:





