Setting up a Laravel development environment on a Mac is a straightforward process. Laravel is a popular PHP framework known for its elegant syntax and powerful features. To get started, follow these steps:
- Install Homebrew:
Homebrew is a package manager for macOS. Open Terminal and run the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- Install PHP:
Laravel requires PHP. Install PHP using Homebrew by running the following command:
brew install php
- Install Composer:
Composer is a dependency manager for PHP. Run the following command to install Composer:
brew install composer
- Install Laravel Installer:
Laravel provides a command-line tool called Laravel Installer. Install it globally using Composer:
composer global require laravel/installer
- Set Up Composer Global Path:
Make sure Composer global binaries are available in your system’s PATH. Run the following command:
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
- Create a New Laravel Project:
Navigate to the directory where you want to create your Laravel project and run the following command:
laravel new project-name
- Start Laravel Development Server:
Navigate to your project directory and start the Laravel development server by running:
php artisan serve
- Access Your Laravel Application:
Open your web browser and go tohttp://localhost:8000
. You should see the Laravel welcome page, indicating that your development environment is set up correctly.
Congratulations! You have successfully set up a Laravel development environment on your Mac. You can now start building amazing web applications using Laravel.