YogeshChauhan . com

How to Install PHP Laravel in MacOS Catalina?

in PHP on January 2, 2021

Step 1: Install Composer

Read this article to add composer in MAC

How To Install PHP Composer In Mac OS Catalina?

Step 2: Install Node.js and npm

Got to Official NodeJS Site and download and install node.js. It will install npm as well.

Step 3: Make sure you have everything installed from the steps above.

Check versions of node.js and npm using terminal commands:


//execute in terminal

node -v

//execute in terminal

npm -v

I’ve demonstrated in the article below how to check if composer is installed globally.

How To Install PHP Composer In Mac OS Catalina?

Step 4: Install Laravel

Download Laravel installer using this command:


//execute in terminal

composer global require laravel/installer

That will download installer the latest 7.x version. If you want previous versions, go to Official Laravel site and change the version from top right corner.

🗒 If you get errors while installing then go to step 5 otherwise skip step 5.

Step 5 (Optional)

Did you get errors like this while installing Laravel?


// errors you might see in the terminal window

- Installation request for laravel/installer ^x.x -> satisfiable by laravel/installer[vx.x.x].
- laravel/installer vx.x.x requires ext-zip * -> the requested PHP extension zip is missing from your system.

Try to follow the steps below ONE BY ONE:


//execute in terminal ONE by ONE

brew install [email protected]
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshr

Restart your Apache server using this Command:


//execute in terminal

sudo apachectl restart

Try to install Laravel again using Step 4.

Step 6: Check if Laravel installer is present

All you need to do is just type laravel in command line:


//execute in terminal

laravel

If you get laravel help commands that means everything went well.

We did it! 🎉

You can start using Laravel now.

☝ But in case you got this error, follow the next steps.


// error you might see in the terminal window

zsh: command not found: laravel

That means you don’t have .composer in your $PATH directory.

Step 7: Add composer to $PATH

Edit bash_profile in one line:


//execute in terminal

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile

You will then also need to refresh your current terminal window with updated bash_profile.


//execute in terminal

source ~/.bash_profile

Try to follow step 6 again and everything should be good.

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to uninstall Cocoapods from the Mac OS? #4 How to add Read More Read Less Button using JavaScript? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

May 7 How to disable right click and drag and drop of images using jQuery? May 7 How to render Lists in React? May 7 What’s the difference between variables in CSS and SCSS (Sass)? May 7 How to define variables in SCSS (Sass)? May 7 How to show and hide an element on click in React? May 5 Use inline if to make a shorter conditional syntax in React

You might also like these

File System Integrity: How to Keep an Eye on Your Files and Folder Change?MiscSolution to Could not cast value of type ‘NSTaggedPointerString’ to ‘NSNumber’SwiftPre-defined DatePipe format options in Angular 9AngularThe fundamental difference between HAVING and WHERE clauses in PostgresPostgresHow to add Go Back button in Swift 5?SwiftCasting in PostgreSQLPostgres