ホーム > Laravel > A relatively easy way to set up Laravel with PHP7.4
Laravel

A relatively easy way to set up Laravel with PHP7.4

Thank you for your continued support.
This article contains advertisements that help fund our operations.

⇨ Click here for the table of contents for Laravel articles

I will be writing about a relatively easy way to set up Laravel with PHP7.4. I initially recommend this method, and once you get comfortable, you may consider introducing Docker.

Since this explanation is geared towards beginners, there may be some lengthy parts, so feel free to skip over anything you already know.

Prerequisite

MacOS bigsur

For Windows users, the specific commands may be different, but the overall process is similar (MAMP⇨XAMPP).

I intend to proceed without the need for typing commands.

This is intended for those who are interested in trying out Laravel.

Some of you may already have PHP, brew, or node installed, please be aware that this guide is assuming a scenario where you have none of these.

Installing Homebrew

Homebrew Official Page

Run the commands listed on the page.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

If the installation is successful, you can check the version with the following command.

brew -v
Homebrew 3.2.7
Homebrew/homebrew-core (git revision 5a5ce7c44e; last commit 2021-08-17)

Installing PHP7.4

Proceed with the commands.

Make sure to carefully check for any errors one by one.

*The echo commands for the 2nd and 3rd might result in errors on Windows.

Install PHP7.4

brew install php@7.4

Set the path

echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.bash_profile

Start PHP7.4

brew services start php@7.4

Close the terminal and any editors you might be using instead of the terminal

php -v

Once the PHP version is displayed, the setup is complete.

Installing Composer

Composer Official

Follow the commands listed on the official page.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Once these commands are completed, a composer.phar file will be created in the location where you are operating the terminal. Move it to a specific location so that you can use the command. Use the following command.

sudo means running the command as an administrator.

mv stands for move, meaning moving the composer.phar file to /usr/local/bin/composer.

sudo mv composer.phar /usr/local/bin/composer

You will be prompted for a password, enter your computer's login password.

Installing Node

There are various articles available for Node, but it is simplest to install it from the Node download page.

Choose the LTS version that suits your PC and follow the installation instructions.

Installing MAMP

Next, install MAMP.

It comes with PhpMyAdmin and is convenient, so it is recommended.

Download MAMP here

Download MAMP & MAMP PRO for your environment from the link above and proceed with the installation.

For Windows users, Xampp is recommended instead (as there may be various issues with MAMP).

Note that while MAMP PRO will be installed automatically, the free MAMP should suffice.

Trying out Laravel commands

From globally installing Laravel to setting up a local server

composer global require laravel/installer
laravel new example-app
cd example-app
php artisan serve

Once the server is up and running, you're all set.

*Due to limitations, database setup and other configurations will be covered in a separate article with screenshots.

Conclusion

This completes the necessary installations for those interested in starting with Laravel!!!

Great job to everyone who made it this far!!!

If you encounter any issues, feel free to contact me via Twitter DM. Until next time!

Popular Articles

Deploying a PHP7.4 + Laravel6 Project to AWS EC2

Implementing Breadcrumbs in Laravel with laravel-breadcrumbs

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!