Introduction
Welcome to this all-inclusive blog post, presenting a comprehensive guide on installing all the essential Laravel system dependencies. Whether you're using macOS, Windows, or Linux (Ubuntu), I've got you covered with detailed instructions for each operating system. So, let's dive right in and get your Laravel environment up and running smoothly!
Everything You Need Explained
Before creating your first Laravel project, you should ensure that your local machine has PHP and Composer installed. In addition, I also recommend installing Node and NPM.
You need to install the above technologies for the following reasons:
PHP - The Programming Language
Laravel is a PHP web framework, meaning it is built using PHP and requires PHP to interpret and execute its code. PHP is a server-side programming language designed for web development, and Laravel leverages PHP's features to provide a powerful and expressive development environment.
Composer - Dependency Management
Composer is a dependency management tool for PHP. It simplifies the process of installing, updating, and managing the libraries and packages that your Laravel application depends on.
Laravel itself is a package that includes various components and libraries. Composer is used to install Laravel and its dependencies easily. It also allows you to add other third-party packages (such as database connectors, caching libraries, and more) to your Laravel project effortlessly.
Node and Npm
Laravel applications often use frontend technologies like JavaScript, CSS, and HTML to create interactive user interfaces. Node.js comes with npm (Node Package Manager), which allows you to manage frontend dependencies and libraries conveniently.
MacOS Installation
PHP and Composer can be installed via Homebrew if you are developing on macOS.
Install PHP
If you have Homebrew installed (https://brew.sh/), open a terminal and run the following command:
brew install php
Verify PHP Installation: After installing PHP, open a terminal or command prompt and type php -v
to check the installed PHP version.
Install Composer (on Linux as well)
Open a Terminal: Press Command + Space
on macOS or Ctrl + Alt + T
on Linux to open a terminal.
Download the Composer Installer: In the terminal, use the following curl command to download the Composer installer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Install Composer: Run the installer using PHP to set up Composer:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Make Composer Executable: Set the correct permissions to make Composer executable globally:
sudo chmod +x /usr/local/bin/composer
Verify Composer Installation:
To verify that Composer is installed correctly, open a new terminal window and type composer -V
. This should display the installed Composer version and other relevant details. Now you have Composer installed and can use it to manage PHP packages and dependencies for your projects.
Install Node and Npm
Using Homebrew (recommended): Open a Terminal and run the following command to install Node.js and npm using Homebrew
brew install node
Using a Package Installer: Alternatively, you can download the macOS installer from the Node.js website (https://nodejs.org) and follow the on-screen instructions to install Node.js and npm.
Verify Installation: Open a terminal and type the following commands to check the installed versions of Node.js and npm:
node -v
npm -v
Windows Installation
Install PHP
Download PHP: Visit the official PHP website (https://www.php.net/downloads.php) and download the latest Windows PHP version.
Install PHP: Run the downloaded installer and follow the on-screen instructions. Make sure to add PHP to your system's PATH during installation.
Verify PHP Installation: After installing PHP, open a terminal or command prompt and type php -v to check the installed PHP version.
Install Composer
Download the Composer Installer: Go to https://getcomposer.org/download/ and download the Composer Windows Installer (.exe file).
Run the Installer: Double-click the downloaded .exe file and follow the on-screen instructions. The installer will set up Composer for you.
Install Node and Npm
Download Installer: Go to the Node.js website (https://nodejs.org) and download the Windows installer (.msi).
Run the Installer: Double-click the downloaded .msi file and follow the on-screen instructions. By default, the installer includes npm, so you don't need to install it separately.
Verify Installation: Open a command prompt or PowerShell window and type the following commands to check the installed versions of Node.js and npm:
node -v
npm -v
Linux Installation
Install PHP
Update your package list
sudo apt update
Install PHP:
sudo apt install php
You can also install specific PHP modules if needed (e.g., for common web applications):
sudo apt install php-mysql # For MySQL database support
sudo apt install php-gd # For image manipulation
Verify PHP Installation: After installing PHP, open a terminal or command prompt and type php -v
to check the installed PHP version.
Install Composer
Refer to the steps outlined above in the MacOS instructions.
Install Node and Npm
Using Package Manager: Open a terminal and run the following commands to install Node.js and npm using the package manager:
Using Package Manager: Open a terminal and run the following commands to install Node.js and npm using the package manager:
sudo apt update
sudo apt install nodejs npm
Verify Installation: In the terminal, type the following commands to check the installed versions of Node.js and npm:
node -v
npm -v
Create a New Application
After the project has been created, start Laravel's local development server using the Laravel Artisan CLI serve command:
php artisan serve
Once you have started the Artisan development server, your application will be accessible in your web browser at http://localhost:8000.
Outro
Congratulations! You've successfully installed all the necessary Laravel system dependencies on your preferred operating system. With your environment now set up, you are well-equipped to embark on an exciting journey into Laravel development.
If you encounter any challenges along the way or seek to expand your knowledge further, please reach out via the comments section. See you in the next blog post.