137

As of now, if I use this command

laravel new blog

It will create a laravel project with the latest version like 5.2, but what if I want to install a specific version, ie. version 5.1?

UPDATE:: I am looking for laravel installer command, is there is any option/parameter for specific version installation?

13 Answers 13

166

Using composer you can specify the version you want easily by running

composer create-project laravel/laravel="5.1.*" myProject

Using the 5.1.* will ensure that you get all the latest patches in the 5.1 branch.

Sign up to request clarification or add additional context in comments.

2 Comments

Could not make an older version (5.3.*) using the Laravel installer version 1.4.1. Instead I had to use composer as per above.
Is there a way to make 'new' create all new projects as the most updated version?
108

use

laravel new blog --version

Example laravel new blog --5.1

You can also use the composer method

composer create-project laravel/laravel app "5.1.*"

here, app is the name of your project

please see the documentation for laravel 5.1 here

UPDATE:

The above commands are no longer supports so please use

composer create-project laravel/laravel="5.1.*" appName

5 Comments

This answer is very similar to the other answers. It is good to add an answer but please make sure that your answer adds new and useful information that is not in the others.
This doesn't answer the question at all; the original question is asking specifically about installing laravel with the laravel/installer package (see https://packagist.org/packages/laravel/installer), not with the composer create-project command
This answer is invalidated since Feb 15, 2017 github.com/laravel/installer/commit/…
Hello, I know that the answer was 5 year ago, but I tryed "laravel new blog --7" but dont work tell me the "--7" option does not exist
@MauEspaña Laravel don't have the option. please use composer for this composer create-project --prefer-dist laravel/laravel:^7.0 blog
21

Installing Laravel via Composer

Once you have PHP and Composer installed, you can create new Laravel projects using Composer.

To install the latest version of Laravel (currently 12.*)

composer create-project laravel/laravel project_name

Installing Laravel via the Laravel Installer

If you prefer using the Laravel Installer, you can install it globally via Composer. Run the following command:

composer global require laravel/installer

Creating a New Laravel Application

After you've installed PHP, Composer, and the Laravel Installer, you are ready to create a new Laravel application. Execute the following command:

laravel new project_name

Installing Specific Versions of Laravel

To install a specific version of Laravel, you can use the following commands:

  • Laravel 11.x

    composer create-project laravel/laravel:^11.* project_name
    
  • Laravel 10.x

    composer create-project laravel/laravel:^10.* project_name
    
  • Laravel 9.x

    composer create-project laravel/laravel:^9.* project_name
    
  • Laravel 8.x

    composer create-project laravel/laravel:^8.* project_name
    
  • Laravel 7.x

    composer create-project --prefer-dist laravel/laravel:^7.0 project_name
    
  • To install Laravel 6.x and below, use:

    composer create-project --prefer-dist laravel/laravel project_name "6.*"
    

Notes

  • Ensure that you have Composer installed and correctly configured on your system.
  • Replace project_name with your desired name for the project.
  • It's always a good practice to check the official Laravel documentation for updates or changes regarding installation procedures.

Comments

20

You can use composer method like

composer create-project laravel/laravel blog "5.1"

Or here is the composer file

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

Comments

15

use laravel new blog --5.1
make sure you must have laravel installer 1.3.4 version.

4 Comments

laravel help -- new to view the documentation for the laravel new command
Not working (Installer 1.4.1). Are they playing games with this option or what?
This answer is invalidated since Feb 15, 2017 github.com/laravel/installer/commit/…
seems like a pretty basic feature, sad they removed it
10

The direct way as mentioned in the documentation:

composer create-project --prefer-dist laravel/laravel blog "6.*"

https://laravel.com/docs/6.x/installation

Comments

7

Year 2022

Since Laravel 5.2 (2017) it is not possible to install a specific Laravel Version via Laravel Installer. Use instead composer create-project. For example:

composer create-project --prefer-dist laravel/laravel blog "7.*"

// That will install Version the latest version of Laravel 7.
// would install: 
"laravel/framework": "^7.29",

composer create-project --prefer-dist laravel/laravel blog "5.*"

// would install:
"laravel/framework": "5.8.*",

composer create-project --prefer-dist laravel/laravel blog

Would install the latest Laravel version on your local machine.

Comments

3

For newer version of laravel:

composer create-project --prefer-dist laravel/laravel=5.5.* project_name

Comments

3

From Laravel 6, Now It's working with the following command:

composer create-project --prefer-dist laravel/laravel:^7.0 blog

Comments

3

Another possibility is to

laravel new my-project --branch 9.x

2 Comments

How does this additional argument change anything from this >7 year old answer?
I'm not sure this works: php laravel new my-project --branch 9.x <snip> Creating a "laravel/laravel" project at "./my-project" Info from https://repo.packagist.org: #StandWithUkraine Installing laravel/laravel (v10.2.6)
-1

you can find all version install code here by changing the version of laravel doc

composer create-project --prefer-dist laravel/laravel yourProjectName "5.1.*"

above code for creating laravel 5.1 version project. see more in laravel doc. happy coding!!

Comments

-1

you can use this command

composer create-project laravel/laravel:^8.*.* exam-app

3 Comments

Thanks for contributing! If you find time please edit an explanation into the answer as it's recommended to explain entirely code-based answers on StackOverflow.
Is this really different enough from stackoverflow.com/a/66026346/4294399 to justify a new answer?
when i run this stackoverflow.com/a/66026346/4294399 i got error.
-1

composer create-project --prefer-dist laravel/laravel project_name "version_num"

Example :: suppose, i would like to create a new project called- blog where i would like to use laravel 6.0 LTS version,, following that command

composer create-project --prefer-dist laravel/laravel blog "6.*"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.