Laravel 12.x Installation

To start building with Laravel 12.x, you first need to set up the environment and install the framework. Laravel runs on PHP and requires a few system-level tools to work properly. In this tutorial, you'll learn how to install Laravel 12.x using Composer, set up a new project, and serve it locally.



System Requirements

Before installing Laravel, make sure your system meets the following requirements:

  • PHP ≥ 8.2 with these extensions: Ctype, cURL, DOM, Fileinfo, Filter, Hash, Mbstring, OpenSSL, PCRE, PDO, Session, Tokenizer, XML
  • Composer 2.x for dependency management
  • MySQL or another supported database (optional for now)
  • Node.js and npm (for frontend asset compilation, optional at this stage)

This setup works across Windows, macOS, and Linux, including environments like XAMPP, MAMP, Homestead, or Herd.


Step 1: Install Composer

Laravel uses Composer to manage its dependencies. If you haven't installed it yet, download Composer from getcomposer.org and follow the installation instructions for your operating system.

To confirm Composer is installed, run:

composer -V

You should see the Composer version printed in your terminal.


Step 2: Install Laravel Installer (Optional)

Laravel offers a global installer that helps create new projects faster. To install it globally, run:

composer global require laravel/installer

Make sure the global Composer vendor/bin directory is in your system's PATH:

  • Linux/macOS: ~/.composer/vendor/bin or ~/.config/composer/vendor/bin
  • Windows: %USERPROFILE%\AppData\Roaming\Composer\vendor\bin

To verify the installer is working, run:

laravel --version

Step 3: Create a New Laravel Project

You can create a new Laravel project in two ways: Using Laravel Installer:

laravel new project-name

Using Composer (without installer):

composer create-project laravel/laravel project-name

Both commands will generate a Laravel project in the project-name folder.


Step 4: Run Laravel Locally

Once your project is set up, you can serve it in different ways depending on your environment.

Option 1: Using Laravel's Built-in Server

This method works in any PHP environment:

php artisan serve

This command starts a local development server at http://127.0.0.1:8000.

Option 2: Using XAMPP or WAMP

If you use XAMPP or WAMP:

  1. Move your Laravel project to the htdocs/ (XAMPP) or www/ (WAMP) directory.
  2. Start Apache and MySQL from the control panel.
  3. In your browser, open:
http://localhost/your-project-name/public

Make sure .env and config/app.php are set correctly for your local environment.

Option 3: Using Laravel Homestead (Virtual Machine)

Laravel Homestead is a pre-packaged Vagrant box. It offers a full development environment:

  • Install Vagrant and VirtualBox
  • Install Homestead via Composer or clone it from GitHub
  • Configure Homestead.yaml and run vagrant up
  • Access your site via:
http://your-homestead-site.test

Option 4: Using Laravel Herd (macOS)

Laravel Herd is a native macOS app to manage Laravel projects easily:

  • Download from laravel.com/herd
  • Open Herd and add your project
  • Herd automatically serves the project at a .test domain like:
http://your-project-name.test

Step 5: Set Folder Permissions (Linux/macOS)

Ensure necessary directories are writable:

sudo chmod -R 775 storage bootstrap/cache

Install Frontend Dependencies

If your Laravel 12.x project uses frontend tools like Vite, Tailwind CSS, or Vue.js, you'll need to install the required Node.js packages. These dependencies are defined in the package.json file located in the root directory of your Laravel project.

To install them, run the following commands from the project root:

npm install

This command will create a node_modules/ folder in the root and download all frontend dependencies. Once installed, you can compile the assets using:

npm run dev

This compiles your CSS and JavaScript files for development. For optimized production builds, you can run:

npm run build

Conclusion

In this tutorial, you learned how to install Laravel 12.x step by step. You explored the system requirements, installed Composer and the Laravel installer, created a new Laravel project, and ran it using different methods such as Laravel's built-in server, XAMPP/WAMP, Homestead, and Herd. You also learned how to set proper folder permissions and install frontend dependencies using npm. With your Laravel environment now fully set up, you're ready to start building powerful web applications.



Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram