Home > Software design >  Deprecation Errors When Trying to Run an Old Laravel Project
Deprecation Errors When Trying to Run an Old Laravel Project

Time:10-22

I have an older Laravel project (v. 5.7.9) that I cloned from my GitHub onto a new machine. The new machine was running PHP 8.1.11, but when trying to composer update the old project errored out, requiring me to use 7.1.

I switched to Composer 1 and downgraded the PHP on my machine to 7.1 so I could composer update (it wouldn't run otherwise).

When I try to composer update now, I get a PGP Fatal error related to memory size and when I try to run the project in my browser, I am met with a boatload of error messages:

Deprecated: 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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1823

Deprecated: Return type of Illuminate\Support\Collection::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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1834

Deprecated: Return type of Illuminate\Support\Collection::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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1846

Deprecated: Return type of Illuminate\Support\Collection::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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1861

Deprecated: Return type of Illuminate\Support\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1802

Deprecated: Return type of Illuminate\Support\Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1781

Deprecated: Return type of Illuminate\Support\Collection::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1750

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1209

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1220

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1232

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1245

Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 838

Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 912

Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 838

Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 912

Deprecated: Return type of Illuminate\Routing\RouteCollection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php on line 347

Deprecated: Return type of Illuminate\Routing\RouteCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php on line 337

Deprecated: Return type of Illuminate\Http\Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Http/Request.php on line 621

Deprecated: Return type of Illuminate\Http\Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Http/Request.php on line 635

Deprecated: Return type of Illuminate\Http\Request::offsetSet($offset, $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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Http/Request.php on line 647

Deprecated: Return type of Illuminate\Http\Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Http/Request.php on line 658

Deprecated: Return type of Symfony\Component\HttpFoundation\ParameterBag::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/http-foundation/ParameterBag.php on line 220

Deprecated: Return type of Symfony\Component\HttpFoundation\ParameterBag::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/http-foundation/ParameterBag.php on line 230

Deprecated: Return type of Symfony\Component\HttpFoundation\HeaderBag::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/http-foundation/HeaderBag.php on line 280

Deprecated: Return type of Symfony\Component\HttpFoundation\HeaderBag::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/http-foundation/HeaderBag.php on line 290

Deprecated: auto_detect_line_endings is deprecated in /Users/[myusername]/Sites/[projectname]/vendor/vlucas/phpdotenv/src/Loader.php on line 162

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 141

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 152

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 164

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 /Users/[myusername]/Sites/[projectname]/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 175

Deprecated: 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 /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Finder.php on line 565

Deprecated: 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 /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Finder.php on line 636

Deprecated: Return type of Symfony\Component\Finder\Iterator\FileTypeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/FileTypeFilterIterator.php on line 42

Deprecated: 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 /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php on line 81

Deprecated: 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 /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php on line 109

Deprecated: 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 /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php on line 61

Deprecated: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php on line 55

Deprecated: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::hasChildren() should either be compatible with RecursiveIterator::hasChildren(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php on line 71

Deprecated: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::getChildren() should either be compatible with RecursiveIterator::getChildren(): ?RecursiveIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php on line 76

Deprecated: Return type of Symfony\Component\Finder\Iterator\FilenameFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/FilenameFilterIterator.php on line 28

Deprecated: Return type of Symfony\Component\Finder\Iterator\PathFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/[myusername]/Sites/[projectname]/vendor/symfony/finder/Iterator/PathFilterIterator.php on line 27

Is it possible to resurrect this old project on a new machine?

CodePudding user response:

it may be easier to upgrade it to a newer version of laravel, you can use 'laravel shift' which is a website you pay for.

or

you could do it by hand. i did that recently and it worked and was fairly easy.

step 1. install a new repo using laravel 9

step 2. copy in the routes, controllers, views, models and what ever else is in the app, resources, public and main folders

step 3. recreate the .env, composer.json and package.json files and run composer install, npm run dev

you may find errors which you can solve, but if you know a bit, it is easier than trying to mangle old versions of php to work.

good luck

  • Related