Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Deprecated and deprecation notice with Laravel 9.x

Hello,

I just started a new project to test Laravel 9.x with PHP 8.1.

I have several deprecated messages and deprecation notice messages during the installation with laravel new.

Do you have the same ?

V

0 likes
13 replies
Nakov's avatar

Once you installed the new PHP version did you run composer global update so that you upgrade the global composer dependencies?

And share what messages are you getting, so we know what do you mean when you say did you got the same? We maybe don't have the same libraries on our machines..

4 likes
waywardson's avatar

@Nakov this is quite old but this worked for me, maybe this will help others

composer update did not do it, that's what everywhere else recommended. composer self-update + composer global update did the trick

here are the errors i was getting:

Deprecated: Using ${var} in strings is deprecated, use {$var} instead

and

Fatal error: Uncaught TypeError: Carbon\Carbon::setLastErrors(): Argument #1 ($lastErrors) must be of type array, bool given

1 like
Nakov's avatar

@22289d and that's exactly what the accepted answer says below.

waywardson's avatar

@Nakov right. i was confirming it worked.

and it just worked again on a different project of mine :)

vincent15000's avatar

@nakov Hey ... yes I have updated with composer global update. I have a very big number of messages. Here are a little example of what I have.

PHP Deprecated:  Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112
Deprecation Notice: Return type of Symfony\Component\Finder\Finder::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/finder/Finder.php:675
Deprecation Notice: Return type of Symfony\Component\Finder\Finder::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/finder/Finder.php:732
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::getChildren() should either be compatible with RecursiveDirectoryIterator::getChildren(): RecursiveDirectoryIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php:85
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::rewind() should either be compatible with FilesystemIterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php:113
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::current() should either be compatible with FilesystemIterator::current(): SplFileInfo|FilesystemIterator|string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php:65
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\FilterIterator::rewind() should either be compatible with FilterIterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/finder/Iterator/FilterIterator.php:30
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\DepthRangeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/local/bin/composer/vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php:41
2 likes
Nakov's avatar
Nakov
Best Answer
Level 73

@vincent15000 composer self-update as well? And then again run the global update.

24 likes
bhojkamal's avatar

@Nakov

On composer self-update on my ubutntu 20.04 server - I got - Command "self-update" is not defined.

On composer global update I got ->

PHP Deprecated:  Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Console/Helper/HelperSet.php on line 104

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Console/Helper/HelperSet.php on line 104

Any idea for this?

1 like
vincent15000's avatar

@Sinnbeck In this issue, someone says that this problem is because I have an old version of symfony console ... is it possible to do something given that symfony console comes with Laravel vendor ?

johnrobin's avatar

I am facing this issue, when I try to configure a project from git to my local repository, anyone suggest how to resolve this.

I am getting more lines similar to this

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 E:\laragon\www\ohcds-backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1355

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 E:\laragon\www\ohcds-backend\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1366

Please or to participate in this conversation.