DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Shrijan
Shrijan

Posted on

Laravel Installation for Macbook. (Without docker)

Prerequisite: homebrew

Disclaimer: This article is for the streamlined installation of laravel command-line tools with PHP and MySQL on MacBook. You can follow the installation and starting guide on laravel.com, I personally like the installation with sail. But this is the traditional way of using laravel on Macbook.

Installation


PHP installation

we will need to install PHP with homebrew, with command

brew install php 
Enter fullscreen mode Exit fullscreen mode

This command will install the latest version of php.

If you have PHP installed already then simply update php

brew update php
Enter fullscreen mode Exit fullscreen mode

MySql Installation

The command is simple enough like

brew install mysql
Enter fullscreen mode Exit fullscreen mode

once installation completed you can start mysql with brew services

brew services start mysql
Enter fullscreen mode Exit fullscreen mode

once mysql is running on your machine you can login to the mysql with

mysql -u root -p 

Enter fullscreen mode Exit fullscreen mode

and enter your password by default it will blank string.

now you can use all of the commands for mysql.

Installation of the composer.

For installing composer goto https://getcomposer.org/download/

and paste the following code found on the installation document.

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

Enter fullscreen mode Exit fullscreen mode

If you try to use the composer command it will not be found and the composer.phar file is not executable. Follow the following command to make it executable and move it to the local bin folder.

$ chmod +x composer.phar
$ mv composer.phar /usr/local/bin/composer
Enter fullscreen mode Exit fullscreen mode

Now try using composer

composer
Enter fullscreen mode Exit fullscreen mode

You must be able to see available commands for the composer listed.

Laravel installer

Install laravel with composer globally

composer global require laravel/installer
Enter fullscreen mode Exit fullscreen mode

Now try using laravel, the command will not found because composer is not been set on the zsh (our terminal)

For zsh

echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >>  ~/.zshrc
source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

If you are bash then use

echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Now you have successfully installed the laravel command line tool. Now you can create laravel application with

laravel new example-app
Enter fullscreen mode Exit fullscreen mode

Now you can start creating your awesome application with laravel.

cd example-app
php artisan serve
Enter fullscreen mode Exit fullscreen mode

Happy Coding....

Top comments (0)

Find what you were looking for? Join hundreds of thousands of developers on DEV so you can:

Β 
🌚 Enable dark mode
πŸ”  Change your default font
πŸ“š Adjust your experience level to see more relevant content