Introduction: Setting up a development environment is crucial for efficient web development, especially when working with Laravel, a popular PHP framework. In this tutorial, we will guide you through the process of configuring a Windows machine for Laravel website development. We will cover the installation of Laragon, Composer, and Git Bash, three essential tools that will streamline your workflow and enhance your productivity. Let's dive in!
Prerequisites: Before we begin, make sure you have the following prerequisites:
- Windows operating system (Windows 10 or later)
- Internet connection
Step 1: Laragon Installation Laragon is a powerful development environment that offers a complete stack for Laravel development. Here's how to install it:
- Visit the Laragon website (https://laragon.org/) and download the latest version of Laragon.
- Run the downloaded installer and follow the on-screen instructions.
- Choose the Laragon installation directory and click "Next."
- Select the components you wish to install (e.g., Apache, MySQL, PHP), and click "Next."
- Choose the desired PHP version and additional tools if needed.
- Select the preferred text editor (e.g., Sublime Text, Visual Studio Code) or leave it as the default.
- Click "Install" and wait for the installation process to complete.
Step 2: Composer Installation Composer is a dependency management tool used in Laravel projects. Here's how to install Composer:
- Visit the Composer website (https://getcomposer.org/) and download the Windows installer.
- Run the installer and follow the on-screen instructions.
- Select the installation location (e.g.,
C:\ProgramData\Composer
). - Choose the PHP executable used by Composer (the Laragon PHP path:
C:\laragon\bin\php\php-{version}\php.exe
). - Click "Next" and wait for the installation process to finish.
- Verify the installation by opening a new command prompt and running
composer --version
. You should see Composer's version information.
Step 3: Git Bash Installation Git Bash provides a command-line interface for executing Git commands on Windows. Here's how to install it:
- Visit the Git for Windows website (https://gitforwindows.org/) and download the Git Bash installer.
- Run the installer and follow the on-screen instructions.
- Select the installation location (e.g.,
C:\Program Files\Git
) and click "Next." - Choose the desired components (e.g., Git GUI, Git Bash) and click "Next."
- Select the preferred default branch name and line ending conversions.
- Choose the terminal emulator used by Git Bash (e.g., Windows Terminal, MinTTY).
- Click "Next" and wait for the installation process to complete.
Step 4: Configuring Laragon and Composer Now that Laragon, Composer, and Git Bash are installed, let's configure them:
- Launch Laragon and click the "Start All" button to start the Apache and MySQL services.
- Open Git Bash by searching for "Git Bash" in the Start menu.
- In Git Bash, navigate to the Laravel projects directory using the
cd
command (e.g.,cd C:/laragon/www
). - Clone an existing Laravel project or create a new one using the Laravel installer (
composer global require laravel/installer
).
Within the Laragon www
folder:
- Open Git Bash by searching for "Git Bash" in the Start menu.
- Navigate to the Laragon
www
directory using thecd
command. By default, Laragon'swww
directory is located atC:/laragon/www
. Use the following command:
cd C:/laragon/www
Once inside the www
directory, you can create a new Laravel project using the Laravel installer. Run the following command:
composer create-project --prefer-dist laravel/laravel your-project-name
Replace your-project-name
with the desired name for your Laravel project. This command downloads the Laravel framework and sets up a fresh installation within a new directory with the specified name.
Composer will begin downloading and installing the necessary Laravel components and dependencies. This process may take a few minutes, depending on your internet connection speed.
After the installation is complete, navigate into the newly created project directory using the cd
command. For example:
cd your-project-name
Congratulations! You have successfully created a new Laravel project within the Laragon www
folder. You can now start developing your Laravel website using Laragon's built-in development environment.
Remember to start Laragon's services (Apache and MySQL) by clicking the "Start All" button in the Laragon interface before accessing your Laravel project through a web browser.
You can now proceed with Laravel development, leveraging Laragon, Composer, and Git Bash to enhance your workflow and build amazing Laravel websites. Happy coding!