117

The fastest and simplest way of installing Laravel is via composer command. From the laravel docs (http://laravel.com/docs/quick), it shows that we can install it with this:

composer create-project laravel/laravel your-project-name --prefer-dist

But, when you run the above command, it will grab the latest version of Laravel. How can I control it if I want to install latest version of 4.0.x? Or, 4.1.x when 4.2 is out?

edi9999
  • 19,701
  • 13
  • 88
  • 127
user1995781
  • 19,085
  • 45
  • 135
  • 236

7 Answers7

186

From the composer help create-project command

The create-project command creates a new project from a given
package into a new directory. If executed without params and in a directory with a composer.json file it installs the packages for the current project.
You can use this command to bootstrap new projects or setup a clean
version-controlled installation for developers of your project.

[version]
You can also specify the version with the package name using = or : as separator.

To install unstable packages, either specify the version you want, or use the --stability=dev (where dev can be one of RC, beta, alpha or dev).

This command works:

composer create-project laravel/laravel=4.1.27 your-project-name --prefer-dist

This works with the * notation.

edi9999
  • 19,701
  • 13
  • 88
  • 127
  • 2
    To play with the dev version (laravel 5): `composer create-project laravel/laravel your-project-name dev-develop` – Jannie Theunissen Oct 09 '14 at 11:46
  • 1
    I tried `laravel/laravel=5.8.38` which is a perfectly valid version and got `Could not find package laravel/laravel with version 5.8.38`. I dropped `.38` and it went through. – sinaza Apr 30 '20 at 20:17
  • @sinaza I think there is no published version called 5.8.38, the latest 5.8 I see is 5.8.35 : https://packagist.org/packages/laravel/laravel#v5.8.35 – edi9999 May 02 '20 at 14:09
  • you can also add ^ to the version so that the installer will install any latest version for example for version 8, which in this time of writing is 8.6.12 `composer create-project laravel/laravel=^8 your-project-name --prefer-dist` – Ron Michael Dec 13 '22 at 04:25
16

Try via Composer Create-Project

You may also install Laravel by issuing the Composer create-project command in your terminal:

composer create-project laravel/laravel {directory} "5.0.*" --prefer-dist
Rohan Khude
  • 4,455
  • 5
  • 49
  • 47
José Bispo
  • 161
  • 1
  • 3
15

Have a look:

Laravel 4.2 Documentation

Syntax (Via Composer):

composer create-project laravel/laravel {directory} 4.2 --prefer-dist

Example:

composer create-project laravel/laravel my_laravel_dir 4.2

Where 4.2 is your version of laravel.

Note: It will take the latest version of Laravel automatically If you will not provide any version.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
6
composer create-project laravel/laravel=4.1.27 your-project-name --prefer-dist

And then you probably need to install all of vendor packages, so

composer install
Toshi
  • 6,012
  • 8
  • 35
  • 58
6

If you want to use a stable version of your preferred Laravel version of choice, use:

composer create-project --prefer-dist laravel/laravel project-name "5.5.*"

That will pick out the most recent or best update of version 5.5.* (5.5.28)

OlaJ
  • 608
  • 7
  • 15
4

To install specific version of laravel try this & simply command on terminal

composer create-project --prefer-dist laravel/laravel:5.5.0 {dir-name}
SPurno
  • 149
  • 1
  • 11
2

Installing specific laravel version with composer create-project

composer global require laravel/installer

Then, if you want install specific version then just edit version values "6." , "5.8."

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

Run Local Development Server

php artisan serve