mecjos's avatar

Artisan Command Deprecation Warnings and Errors

I get errors below while running php artisan sail:install command or any php artisan command. Everything was normal. I don't know reason of this situation. I deleted vendor folder and re run "composer install" command but it's same.

PS D:\Work\webdev\matolye\backend> php artisan sail:install
PHP Deprecated:  Return type of Illuminate\Container\Container::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 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1355

Deprecated: Return type of Illuminate\Container\Container::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 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1355
PHP Deprecated:  Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1366

Deprecated: Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1366
PHP Deprecated:  Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1378

Deprecated: Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1378
PHP Deprecated:  Return type of Illuminate\Container\Container::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1391

Deprecated: Return type of Illuminate\Container\Container::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1391
PHP Deprecated:  Return type of Illuminate\Config\Repository::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 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 141

Deprecated: Return type of Illuminate\Config\Repository::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 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 141
PHP Deprecated:  Return type of Illuminate\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 152

Deprecated: Return type of Illuminate\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 152
PHP Deprecated:  Return type of Illuminate\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 164

Deprecated: Return type of Illuminate\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 164
PHP Deprecated:  Return type of Illuminate\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 175

Deprecated: Return type of Illuminate\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 175
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 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Collections\Collection.php:1443
Stack trace:
#0 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Collections\Collection.php(13): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', 'D:\Work\webdev\...', 1443)
#1 D:\Work\webdev\matolye\backend\vendor\composer\ClassLoader.php(571): include('D:\Work\webdev\...')
#2 D:\Work\webdev\matolye\backend\vendor\composer\ClassLoader.php(428): Composer\Autoload\includeFile('D:\Work\webdev\...')
#3 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Collections\helpers.php(15): Composer\Autoload\ClassLoader->loadClass('Illuminate\Supp...')
#4 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(130): collect(Array)
#5 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(106): Illuminate\Foundation\PackageManifest->build()
#6 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(89): Illuminate\Foundation\PackageManifest->getManifest()
#7 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config('aliases')
#8 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()
#9 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(237): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap(Object(Illuminate\Foundation\Application))
#10 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith(Array)
#11 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#12 D:\Work\webdev\matolye\backend\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 {main} in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Collections\Collection.php on line 13
PHP Fatal error:  Uncaught Error: Class "Illuminate\Support\Collection" not found in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Collections\helpers.php:15
Stack trace:
#0 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Support\Traits\ReflectsClosures.php(24): collect(Array)
#1 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Support\Traits\ReflectsClosures.php(44): Illuminate\Foundation\Exceptions\ReportableHandler->closureParameterTypes(Object(Closure))
#2 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\ReportableHandler.php(62): Illuminate\Foundation\Exceptions\ReportableHandler->firstClosureParameterType(Object(Closure))
#3 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(234): Illuminate\Foundation\Exceptions\ReportableHandler->handles(Object(Symfony\Component\ErrorHandler\Error\FatalError))
#4 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(88): Illuminate\Foundation\Exceptions\Handler->report(Object(Symfony\Component\ErrorHandler\Error\FatalError))
#5 D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(130): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Symfony\Component\ErrorHandler\Error\FatalError))
#6 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#7 {main}
  thrown in D:\Work\webdev\matolye\backend\vendor\laravel\framework\src\Illuminate\Collections\helpers.php on line 15
0 likes
12 replies
Snapey's avatar

These are associated with an incompatible php version.

jaberwiki's avatar

Your php version and laravel version is conflicting

2 likes
MohamedTammam's avatar

How are you using sail while running PHP from your local? the error mostly regarding incompatible php version as others mentioned above.

Delete your vendor folder.

Then from WSL run the following.

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd)":/opt \
    -w /opt \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

Change php81 to the version for you app.

Then, for running artisan command use ./vendor/bin/sail artisan ... from WSL

mecjos's avatar

@MohamedTammam I'm not trying to use artisan in sail container. I haven't install sail yet. I was tyring to install sail on my local. PHP version is compatible with laravel 8.12. First I got "Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255" this error then tried to upgrade sail package. then that's the situation.

MohamedTammam's avatar

@mecjos Try deleting vendor folder. Then run composer install command that I sent using WSL. and then test again using sail.

mecjos's avatar

Everyone has same opinion about it's php version problem. But my php version is 8.2.4 and Laravel 8.12. I was already using there wasn't problem. I wanted to install sail on my local and I get an error related with "@php artisan package:discover --ansi" this. I thought it was about sail version and installed latest version but nothing changed. Then I returned ald composer.json file, deleted vendor folder and reinstalled dependencies.. here we are.. All of there are on local computer. Since I don't have php on wls I make sail installing operation on local.

mecjos's avatar

@gych but I was using it. I don't think this is related with php version.

gych's avatar
gych
Best Answer
Level 29

@mecjos Its clearly giving you PHP Deprecated errors, which you would get when using a newer PHP version that doesn't support the specific code that used to work fine in older PHP versions.

mecjos's avatar

@gych ok I will check the version in homestead.. normally I run artisan commands in homestead environment. But I can't connect vagrant after installed wls.. that's another problem. )

gych's avatar

@mecjos Ok just downgrade the version to PHP 8.1 and it should work without the errors. Laravel versions starting from Laravel 9 support PHP 8.2

Omarelewa's avatar

I got a similar problem when I setup homestead and try to run an old project which uses php7.4. After alot of trials I found the problem is coming from the nginx configuration for my site. So, I went to /etc/nginx/sites-enabled/{your-site.test} and changed this line

from fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;

to fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

Hope this may help someone.

Please or to participate in this conversation.