Laravel on local machine - artisan errors

48 Views Asked by At

I have a Laravel project (Laravel 7) locally saved on my computer. The live version is uploaded manually to a shared server (old-school fashion). For various reasons we can't update this project to a newever version of Laravel.

I have a number of other projects all using different version of Laravel depending on their age.

For the most recent project (Laravel 10) I updated composer to perform various package installs etc. But now my older project like the LAravel 7 one doesn't let me run anything via artisan. I get the following error when trying to call artisan to do anything on my Laravel 7 project:

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 C:\moproject\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 C:\moproject\vendor\laravel\framework\src\Illuminate\Support\Collection.php:1349
Stack trace:
#0 C:\moproject\vendor\laravel\framework\src\Illuminate\Support\Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', 'C:\\xampp2\\htdoc...', 1349)
#1 C:\moproject\vendor\composer\ClassLoader.php(576): include('C:\\xampp2\\htdoc...')
#2 C:\moproject\vendor\composer\ClassLoader.php(427): Composer\Autoload\{closure}('C:\\xampp2\\htdoc...')
#3 C:\moproject\vendor\laravel\framework\src\Illuminate\Support\helpers.php(110): Composer\Autoload\ClassLoader->loadClass('Illuminate\\Supp...')
#4 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(130): collect(Array)
#5 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(106): Illuminate\Foundation\PackageManifest->build()
#6 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(89): Illuminate\Foundation\PackageManifest->getManifest()
#7 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config('aliases')
#8 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()
#9 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(230): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap(Object(Illuminate\Foundation\Application))
#10 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith(Array)
#11 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#12 C:\moproject\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 {main} in C:\moproject\vendor\laravel\framework\src\Illuminate\Support\Collection.php on line 11

In Collection.php line 11:

  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $of   
  fset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\moproject\vendor\laravel\framework\src\Illuminate\Support\Co   
  llection.php:1349                                                                                                                                                                                   
  Stack trace:                                                                                                                                                                                        
  #0 C:\moproject\vendor\laravel\framework\src\Illuminate\Support\Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...   
  ', 'C:\\xampp2\\htdoc...', 1349)                                                                                                                                                                    
  #1 C:\moproject\vendor\composer\ClassLoader.php(576): include('C:\\xampp2\\htdoc...')                                                                                         
  #2 C:\moproject\vendor\composer\ClassLoader.php(427): Composer\Autoload\{closure}('C:\\xampp2\\htdoc...')                                                                     
  #3 C:\moproject\vendor\laravel\framework\src\Illuminate\Support\helpers.php(110): Composer\Autoload\ClassLoader->loadClass('Illuminate\\Supp...')                             
  #4 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(130): collect(Array)                                                                   
  #5 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(106): Illuminate\Foundation\PackageManifest->build()                                   
  #6 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(89): Illuminate\Foundation\PackageManifest->getManifest()                              
  #7 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config('aliases')                          
  #8 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()                        
  #9 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(230): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap(Object(Illuminate\Found   
  ation\Application))                                                                                                                                                                                 
  #10 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith(Array)                          
  #11 C:\moproject\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()                                
  #12 C:\moproject\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Conso   
  leOutput))                                                                                                                                                                                          
  #13 {main}           

Not having artisan working is a real pain!!

PHP version locally is 8.2.12, which is also provided in my project's composer ("php": "^7.2.5||^8.2.12").

I've tried running "composer update" but after "Installing dependencies..." and "Generating optimized autoload files..." I get the same error, plus the following line:

 Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255

How do I resolve this?? Many thanks

0

There are 0 best solutions below