Use the latest Laravel version - php

Lately l've been working with Laravel. I use composer to install packages and artisan for commands.
The problem is that my machine uses Laravel 5.4 not 5.7.
When i run phpinfo() the result is PHP Version 7.2.7. Do you think that the problem is that i don't use the latest version of xampp which it has included php 7?

Based on comment, yes it is related to PHP version. Your PHP CLI version is too low to support newer version of laravel. You need to update or switch PHP CLI to newer version. Server and CLI PHP are separate packages and might have different versions.
No it is not related to PHP version (in this case).
Probably you ran
composer install
which will install dependencies in versions defined in composer.lock to update dependencies run
composer update
For differences between install and update you can refer to this question

From the comments:
laravel/framework v5.5.9 requires php >=7.0 -> your PHP version (5.6.19) does not satisfy that requirement.
Run php -i in the Terminal. Looks like your webserver and your command line (which Composer uses) are using different versions of PHP.

Laravel version depends on your installation way. It's not related to your PHP or XAMPP version. And you are using the latest PHP version, so don't worry about PHP version.
Read the Laravel installation to install the latest version of laravel.

If you using package laravel/installer
Update this package
composer global update
and try to run
laravel new my-app

Related

How to install laravel 7 with php version 8

I am geeting error when trying to install laravel 7 using php version 8. Is there any way i can solve this issue.
This message is telling you that no version of Laravel is available for the given version constraint (^7.0) and your PHP version.
Said otherwise all Laravel version from the 7.0 to the latest 7.x (^7.0) aren't compatible with your PHP version (which is probably too old).
You could also have missing extensions that are required by Laravel.
Three options here:
You try to fix those version problems and try again.
You bypass Composer checks by using the --ignore-platform-reqs flag: composer create-project --ignore-platform-reqs laravel/laravel:^7.0 blog. Composer will ignore the "platform requirements" and will install Laravel, however it might not work well.
You remove the version constraint and Composer will install the latest compatible Laravel version (if there is one, it depends on your extensions): composer create-project laravel/laravel blog.
You can check the PHP version by doing php --version, Laravel 7 requires at least PHP 7.2.

Upgrade laravel

Hello after I installed Laravel,
I try to update the version 5.5 to 5.6 and unable to throws me an error:
- laravel/framework v5.6.9 requires php ^7.1.3 -> your PHP version (7.0.10) does not satisfy that requirement.
I use XAMPP with PHP 7.2.10.
I installed Composer with php 7 And does not help.
Thanks
Have a look at your composer.json. It is possible that there is a configuration parameter config.platform.php which contains the value 7.0.10. This feature allows to simulate a specific PHP version to composer. If you don't need it, you can remove it or force composer to install anyway by using the --ignore-platform-reqs parameter when updating the packages.
If you are on Linux Debian, you can easily install the latest version of php with sudo apt-get install php x.x. On windows, this link might help. Then, try installing or upgrading Laravel from cmd and it should work sweet! Re-installing the latest verion of XAMPP may also do the work for you.
You have to update your system's PATH environment variable so that it finds the newer version of php from your command line. You might have more than one installed right now, so it uses the first one it finds when it looks through the directories defined in your PATH. After updating the path variable, you might have to log out for it to apply.
You can check the version used by your command line with php --version. To see which version Apache is configured with, use phpinfo().

Tell composer which PHP version to use

I have two projects running php7.0 and 5.6. Now the default version of php cli is 7.0. I need to run composer-update on project 5.6 but the composer is reading php7.0 so it will throw an error since there are features that only compatible in 5.6. Is there a way to tell composer which version to use during composer-install and composer-update without changing the default php-cli?
Yes, you just have to specify which PHP version to use by directly calling the intended PHP bin file.
So, instead of
php composer.phar update
You have to use something like
/path/to/php5.6/bin/php composer.phar update
In my case, on a CentOS server with Plesk (default PHP version was 5.4, but I also had 5.6 and 7.0 installed), I had to use :
/opt/plesk/php/5.6/bin/php composer.phar update

Laravel Installer Version 1.3.3 and Framework 5.2 cannot be removed from my MAC

Trying to install Spark Laravel 3 I realized that my current laravel installer was version 1.3.3. Laravel Spark request version 1.3.4.
several procedures were made in order to use version 1.3.4.
update composer
erase laravel installer from ~/.composer/vendor/bin
etc.
no matter what I do, it seems that the installer is loaded and used from some cache. consequently an old version 1.3.3 is installed.
Running composer global require "laravel/installer=~1.3.4" version 1.3.4 is installed. running laravel -V says 1.3.4 but then when I install in
localhost/laravel
and run laravel -V it says 1.3.3
UPDATE//////////////////////////////////////////////////
following bagus-tesa advise i used composer global remove laravel/installer with success.
Im confused, because despite in ~/.composer/bin calling laravel -V displays 1.3.4 when I install laravel spark it always install laravel version 5.2 instead of version laravel 5.3
anyone knows if spark laravel has a place in configuration to force installing laravel 5.3 version? brgds
Install
composer global require "laravel/installer=~1.3.4"
Uninstall
composer global remove laravel/installer
laravel installer is just an alternative way to create laravel project. I have not find it so useful in my opinion.
You can do the same thing using composer:
composer create-project laravel/laravel=5.3.0 projectName --prefer-dist
If it does not work, make sure you have the minimum PHP version required for the chosen laravel version

Skip composer PHP requirement

We are using PHPCI and composer. The server which runs PHPCI is on PHP 5.3.
For a project we added the Facebook PHP SDK, using composer. It requires PHP 5.4.
Composer gets triggered by PHPCI and get executed. But because the CI server just got PHP 5.3 composer failed with the error message:
facebook/php-sdk-v4 4.0.9 requires php >=5.4.0 -> no matching package found.
This let fail my build in PHPCI, of course.
Is there a possibility to skip this requirement? Maybe by adding an option to composer.json? Or a parameter to composer.phar call?
I've found the option:
composer install --ignore-platform-reqs
Ignore platform requirements (php & ext- packages).
Alternative: Specify your projects' PHP version
You can skip the platform checks by configuring composer.json#/config/platform/php with the PHP version to use.
Composer will fetch packages based on that configured PHP version then.
So when you need to tell Composer the PHP version for your projects dependencies, you can (and should) specify the PHP version if different than the PHP version you execute composer with in your composer.json project configuration file (AKA root package):
{
"config": {
"platform": {
"php": "5.6.6"
}
}
}
Here PHP 5.6.6 version is exemplary, it could be 8.0.4 or any other PHP version.
This also documents the target (platform) PHP configuration. Additionally installed PHP extensions and library versions can be specified.
Compare: Config: platform - Composer documentation
For many commands, you can tell composer to bypass php version check, with parameter "--ignore-platform-reqs":
composer COMMAND --ignore-platform-reqs
this will bypass php version specification.
Be aware that the software may work or not: php version specification is there because somewhere in the code is needed at least the specified php version, so if you use that code the software will break.
If anything requires a specific version of PHP, it won't run in a lower version of PHP. You will properbly still recieve errors when bypassing the PHP requirement.
Btw, PHP 5.3 is no longer maintained, I would strongly recommend updating the PHPCI server.

Categories