HEROKU error: During inheritance of ArrayAccess - php

This is the log of heroku, previous version of my code was running perfect but I change some code and have this error.
Rollback is no t solution same error now...
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/php
-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
- php (8.1.0)
- ext-mbstring (bundled with php)
- composer (2.1.14)
- apache (2.4.51)
- nginx (1.20.2)
-----> Installing dependencies...
PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/build_3007ab05/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1349

I got the exact same error recently. My local php version is 8.0.13 and it is working fine, but when I uploaded it to heroku (the php version used here is 8.1) I got the error.
To solve the problem, I specified my php version in the composer.json to the exact same local php version that I'm using like this:
{
"require": {
"php": "8.0.13"
}
}
Don't forget to update the composer.lock, then upload it to heroku. Heroku will use that exact version.
I know it is not recommended to specify the exact version per https://devcenter.heroku.com/articles/php-support, but it is working fine as a workaround.

Related

Symfony error when attempting to generate Doctrine proxy files

I have a PHP solution which is being moved from PHP7.4 -> PHP8.1. This required updating many packages used, such as Symfony and Doctrine. Everything seems fine, but when I go to run my deployment script, which re-generates Doctrine proxy files, I encounter an error:
Fatal error: Uncaught Symfony\Component\Console\Exception\LogicException: An option named "em" already exists. in /usr/local/store/vendor/symfony/console/Input/InputDefinition.php:232
I've tried playing with the Doctrine and Symfony versions which are required (I've tried symfony/console 5.4.16 and 6.2.5, and I had to downgrade doctrine/dbal from 3.5.1 to 2.13.9 to fix a different issue in the same deployment step), but I can't find any combination of packages that solves this issue.
The deployment is running the following:
php ./vendor/bin/doctrine-module orm:generate-proxies --em=orm_databasename

can't run laravel 5.7 on php8

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

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 :)

Application error on heroku - No 'composer.json' found

When I try to access my heroku page it says
"Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details"
This is my build log:
PHP app detected ! WARNING: No 'composer.json' found. Using
'index.php' to declare app type as PHP is considered legacy
functionality and may lead to unexpected behavior. Bootstrapping...
Installing platform packages... NOTICE: No runtime required in
composer.lock; using PHP ^5.5.17 apache (2.4.20) nginx (1.8.1) php
(5.6.30) Installing dependencies... Composer version 1.4.1 2017-03-10
09:29:45 Preparing runtime environment... NOTICE: No Procfile, using
'web: heroku-php-apache2'. Checking for additional extensions to
install... Discovering process types Procfile declares types -> web
Compressing... Done: 13.9M Launching... Released v119 deployed to
Heroku Build finished Blogs Careers Documentation
========================================================================

Heroku Push rejected, failed to compile PHP app

Deployment to Heroku for my project has been working fine until today. Last update to my composer file was including a php class to my class map in composer.json. Now Heroku Deployment fails with this error message
-----> Removing .DS_Store files
-----> Fetching custom git buildpack... done
-----> PHP app detected
-----> No runtime required in composer.json, defaulting to PHP 5.6.11.
-----> Installing system packages...
- PHP 5.6.11
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
! Push rejected, failed to compile PHP app
I have tried updating composer, but updating composer.lock doesn't solve this issue for me.
Any help would be appreciated.
Heroku is having problems at the moment: https://status.heroku.com/incidents/792
Don't worry, it's not just you!

Categories