Installing specific laravel version with composer create-project
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.
Installing specific laravel 5 version with composer create-project
you can do:
composer create-project laravel/laravel myproject --prefer-dist v5.1.8
To see available versions, you can visit its packagist page (lower right):
https://packagist.org/packages/laravel/framework
UPDATED:
There is no actually a tag for v5.1.8 for package laravel/laravel,
Your issue is the framework(core) of laravel..
What you can do to solve it is to edit your composer.json:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.8"
},
And do composer update "laravel/framework"
Installing Laravel with Composer create-project - how to use the newest version?
It looks lile your environment is insufficient for L7 (like too old PHP version, missing required extensions etc). You should ensure your environment fulfills Laravel requirements:
- PHP >= 7.2.5
- BCMath PHP Extension
- Ctype PHP Extension
- Fileinfo PHP extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
Tokenizer PHP Extension
XML PHP Extension
https://laravel.com/docs/7.x/installation#server-requirements
Also keep in mind that php-cli version you use may be different from what your httpd is using (i. e. due to $PATH
and multiple PHP versions are installed).
Why does the installed Laravel version through composer not match the Laravel version when installed?
When you run command composer create-project laravel/laravel
you are creating a project based on the composer package laravel/laravel (source code at GitHub). This project is the Laravel boilerplate code which is typically used as a template for your own project. Using the boilerplate project is optional, you can, in theory, create a new Laravel project completely from scratch, though it's a tedious task. The version you choose when you create the project corresponds to the version of that project for example choosing version 9.1 creates this as a new project locally.
As you can see in all versions 9+ the dependency is laravel/framework: ^9.X
where X is what the latest version the framework happened to be at when they tagged the release (probably). However the key is that ^
means composer is allowed to install the latest version based on semantic versioning. More information on this is here but generally speaking if you specify ^9.X.Y
as a dependency composer is allowed to install the latest package that has a major version of 9 so anything from 9.0.0 to 9.1000.1000 (or more) could be installed.
If you want to install a specific version of the Laravel framework you need to modify your composer.json
file after you have created your boilerplate project and change the version to the exact version you want. For example something like:
"laravel/framework": "9.0",
will force install version 9.0 for the framework. I do not generally recommend doing this because the latest version will have security and bug fixes which you will not be getting.
How to specify Lumen (or Laravel) version on new installation?
Create a project using the composer command :
Create a Laravel 5.1 project into the blog folder :
composer create-project laravel/laravel blog "5.1.*"
Create a Lumen 5.1 project into the blog folder :
composer create-project laravel/lumen blog "5.1.*"
Related Topics
Strip All HTML Tags, Except Allowed
How to Get Rid of MySQL Error 'Prepared Statement Needs to Be Re-Prepared'
Get Week Number (In the Year) from a Date PHP
PHP Check Whether Property Exists in Object or Class
How to Replace (Monkeypatch) PHP Functions
How to Retrieve Utf-8 Accented Characters from Access via Pdo_Odbc
Find Common Values in Multiple Arrays with PHP
Using Strtotime for Dates Before 1970
How to Implement Pagination in PHP
Undefined Variable Problem with PHP Function
Binding Parameters for Where in Clause with Pdo
Google_Service_Directory - (403) Not Authorized to Access This Resource/Api
Ffmpeg Progress Bar - Encoding Percentage in PHP
How to Sort an Array of Utf-8 Strings