can't run laravel 5.7 on php8 - php

hi guys I need help for this case
I can't run laravel 5.7 on php8, when I do "php artisan serve"
I got error:
thrown in /var/www/html/myProject/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 838
PHP Fatal error: Uncaught ErrorException: Method ReflectionParameter::getClass() is deprecated in /var/www/html/myProject/vendor/laravel/framework/src/Illuminate/Container/Container.php:838
I have tried to update composer required php version form "^7.1.3" to "php": "^7.1.3|^8.0",
and when I run composer update I got another error.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework[v5.7.0, ..., 5.7.x-dev] require php ^7.1.3 -> your php version (8.0.3) does not satisfy that requirement.
- Root composer.json requires laravel/framework 5.7.* -> satisfiable by laravel/framework[v5.7.0, ..., 5.7.x-dev].
I hope any body sharing what is solution for this case

Both errors are related.
According to The Official Docs Laravel 5.7 only supports PHP >= 7.1.3.
Trying to force it to run on PHP8 will cause some funky things as PHP8 has a lot of game changing fixes/migrations/deprecation. All of which can be found here.
If you want to use PHP8, use Laravel 8. If you want to use Laravel 5.7, use PHP7.
If you must use PHP8 and Laravel 5.7, I suggest you change the composer requiremnet to "php": "^8.0", but be prepared to troubleshoot a lot.

Laravel 5.7 is not compatible with PHP 8. If you want to get PHP 8 support, make sure you're at the latest version of Laravel 6, 7, or 8.
There are also a couple of commonly used dependencies you'll need to update in your composer.json file:
PHP to php:^8.0
Faker to fakerphp/faker:^1.9.1
PHPUnit to phpunit/phpunit:^9.3

You can putting exit($e); in App\Exceptions\Handler::report() to give a better error message.

delete vendors file
then run the command composer install

Related

How to upgrade Laravel 6 project to Laravel 9

I've been asked on my job to update a Laravel 6 project to version 9. I'm having a lot of issues, i can't even test the project cause it's giving me a lot of errors.
First i wanted to check the exact laravel version (i've been told it's 6.2), but I can't even check it with php artisan --version or use php artisan...
Also I would like to know how to do the update, since i can only find enough information to update from 8 to 9 on the official website.
Thanks.
Things i've tried:
-Changed this on composer.json:
"require": {
"php": "^7.3|^8.0",
.....
},
-Tried this composer commands:
composer update
composer install
composer update --no-scripts
composer require laravel/framework
-I get this errors:
During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with Arr
ayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\Users*******\
Documents\Project\project\vendor\laravel\framework\src\Illuminate\Support\Collection.php:1277
or
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
Thanks.
I've been able to upgrade laravel 6 to 7 with success.
The first problem was that my PHP version was too high, apparently higher versions does not work for the upgrade, so I had to downgrade PHP (im using Xampp so i just had to change 'apache' and 'php' folders on Xampp folder from 7.2.5 version).
My project had some external dependencies that I had to upgrade first before running 'composer update'. This was the main problem and I didn't know about that. (In my case barryvdh/laravel-ide-helper and laravel/ui).
After I fixed that things, I just ran 'composer update' and everything was working. I'll try to upgrade now to laravel 8 and 9, hope it's the same. Thanks to everyone for the answers and hope this can help others.

Laravel in PHP 8 dev

I have a docker container with php 8.0.0-dev and composer. I want to create a Laravel application to test the new PHP but I have some errors.
When I try to create a new laravel project with the command:
composer create-project laravel/laravel test
The error I get is that I don't have the required PHP even though php 8.0.0 is greater than php 7.x.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework v5.6.9 requires php ^7.1.3 -> your PHP version (8.0.0-dev) does not satisfy that requirement.
- laravel/framework v5.6.8 requires php ^7.1.3 -> your PHP version (8.0.0-dev) does not satisfy that requirement.
...
...
Can I skip the php version check somehow?
I have tried with
--prefer-dist
and
--ignore-platform-reqs
but i obtain this error:
Problem 1
- Conclusion: don't install laravel/laravel v7.25.0|remove laravel/laravel v7.25.0
- Installation request for laravel/laravel v7.25.0 -> satisfiable by laravel/laravel[v7.25.0].
Any idea?
Thanks!!!
Laravel supports PHP 8.0 right now, however still some packages are not updated. It affects also some of the PHP extensions:
https://blog.remirepo.net/pages/PECL-extensions-RPM-status
First, make sure you're at the latest version of Laravel 6, 7 or 8 to
get PHP 8 support. Then make sure you're on the very latest version of
any first-party package from Laravel like Passport, Cashier, Dusk,
etc.
There are also a couple of commonly used dependencies you'll need to
update in your composer.json file:
PHP to php:^8.0
Faker to fakerphp/faker:^1.9.1
PHPUnit to phpunit/phpunit:^9.3
Finally, run composer update to update other packages. Make sure to
test your application before updating production. That's it! Enjoy PHP
8!
Source: https://blog.laravel.com/laravel-php-8-support
You are trying to install laravel 5.
For PHP 8 you need at least laravel 6,7 or 8
I prefer laravel 8 (last one)
If you use docker according to laravel 8 documentation you can create project with command:
curl -s https://laravel.build/example-app | bash

Can't start Laravel 5.4 application on production (PHP 5.6)

I have Laravel 5.4 installed on PHP 5.6.4 server, and i can't start the app. Everything works ok locally with the same configuration, but on the server i get this error:
(1/1) FatalErrorException syntax error, unexpected '?', expecting variable (T_VARIABLE)
in PDOConnection.php line 24
CLI version is 7.2 on the server, and phpinfo() shows 5.6.40. The error shows on pages where DB access is needed. When there's no DB requests it works fine.
Thanks :)
PDOConnection.php is a file from doctrine/dbal package, and its line 24 is incompatible with PHP 5.4 (using ?array).
Laravel 5.4 has doctrine/dbal~2.5 in its require-dev, but in version 2.5 there is no such issue (line 40).
It seems that you have to delete vendor folder and run composer install again, that will install needed dependencies.
Added:
#aynber pointed that your issue is with installing dependencies with PHP 7.2 and running on PHP 5.6, so after removing vendor folder and before reinstalling you should add this to your composer.json:
"config": {
"platform": {
"php": "5.6.40"
}
}
Source
Are you sure you're using Laravel 5.4? Laravel 5.4 should be using doctrine/dbal#~2.5 where there is only a comment on line 24. It appears you are using at least version 2.9, which uses nullable types which is only available in PHP 7.1+.
Your options:
Update your PHP version
Remove and reinstall laravel/framework#5.4
Thanks for your help, i fixed the problem.
I cleared the composer cache with 'composer clearcache', then i ran:
composer which, which returned the composer path
and then i ran
php -d allow_url_fopen=on COMPOSER_PATH_FROM_PREV_STEP update
and it updated all dependencies to work with PHP5.6 :)

Upgrading Laravel 5.4 to latest version (5.7)

I am working on Laravel 5.4 with PHP version 5.6.4.
My goal is to upgrade my project to Laravel 5.7 with PHP 7.1.
Now my question is: Do I have to upgrade to 5.5 > 5.6 > 5.7 or can I go directly from 5.4 to 5.7?
There are some articles on documentation. You can upgrade to 5.7 directly but be sure to modify critical sections from this links 5.5->5.6, 5.6->5.7. And make a backup of current project first
Better to upgrade 5.5 first an then go with 5.6 and 5.7 because if you see in 5.5 and 5.6 upgrade guide there are some packages also need to upgrade so you better go with the step by step.
5.4 to 5.5
5.5 to 5.6
5.6 to 5.7
For older versions, you can look at
5.3 to 5.4
4.2 to 5.3
From my point of view, it would help to upgrade step by step. This helps to to see whether your application is already compatible with all changes that need to be made.
If you upgrade to 5.7 directly and face larger problems due to the changes, your quickest option is to downgrade to 5.4 again.
If you upgrade to 5.5 in the first step, you can make your application compatible to 5.5, test it thoroughly, deploy it, and start to test what needs to be done for the upgrade to 5.6.
Just update your laravel/framework dependency to 5.7.* in your composer.json file. Since you are upgrading from 5.4 to 5.7, then you can easily just run
composer update
And if you modified some of Laravel's Traits or Methods in your 5.4 application, then you can check here for more info
Just update your laravel/framework dependency to 5.7.* in your composer.json file:
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0"
},
After, run this command on your command prompt: composer update
You will achieve success and your Larvael will change to version 5.7, more details are available on upgrade guide
No,you sholud not upgrade step by step, only you can do this :
https://laravel.com/docs/5.7/upgrade
For updating Laravel 6.x (Which means any subversions to V6)
Just run this command
cd [laravel installation directory]
composer update
You must have composer installed on your VM or PC.
For Linux users only:
Composer directory must be owned by current user
//Check ownership
ls -la ~/ | grep ".composer"
//If you don't own the directory
chown -R [user]/[user] ~/.composer
Message me on any social media #smitpatelx Or leave a comment if you need any help or if your usecase differ from the above.

Laravel Upgrade Error With Whoops

I just updated my Laravel 5.4.23 to 5.5 and tried running my tests for PHPUnit and I am receiving the following error and I am trying to scour around the internet and find out people who have done so and have received the same error message but have not had any luck.
Has anyone received this error?
Call to undefined method Whoops\Handle\PrettyPageHandler::setApplicationPaths()
setApplicationPaths() doesn't exist in the 2.0.0 release of the filp/whoops library. Essentially, it's not a problem with Laravel 5.5 but with that specific version of Whoops. I experienced the same issue until I updated the library version I was using to the newest stable version of Whoops (2.1.10), which I did by changing the dependency version in my composer.json file "filp/whoops" : "~2.1.10" Once you make that change, run composer update and the error should go away.
(1/5/2018) Editing to add that this doesn't appear to be an issue in later releases of Laravel 5.5, so changes to the version of filp/whoops should not be necessary at this point.
Have you tried clearing all the caches via php artisan cache:clear or php artisan view:clear?

Categories