0

For the first time I am trying to run my Laravel project on newly Arch Linux machine and when running composer require laravel/installer command I get this error:

Info from https://repo.packagist.org: #StandWithUkraine
Using version ^4.2 for laravel/installer
./composer.json has been updated
Running composer update laravel/installer
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Deprecation Notice: 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 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Container/Container.php:1270
Deprecation Notice: Return type of Illuminate\Container\Container::offsetGet($key) should either be compatiblewith ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Container/Container.php:1281
Deprecation Notice: 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 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Container/Container.php:1293
Deprecation Notice: 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 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Container/Container.php:1306
> @php artisan package:discover --ansi
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 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1349
Stack trace:
#0 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /home/brankoo/Desktop/web/vendor/composer/ClassLoader.php(571): include('...')
#2 /home/brankoo/Desktop/web/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#3 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Support/helpers.php(110): Composer\Autoload\ClassLoader->loadClass()
#4 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(130): collect()
#5 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(106): Illuminate\Foundation\PackageManifest->build()
#6 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): Illuminate\Foundation\PackageManifest->getManifest()
#7 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config()
#8 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()
#9 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap()
#10 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith()
#11 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#12 /home/brankoo/Desktop/web/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#13 {main} in /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line11

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 $offset): bool, or t  
he #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/brankoo/  
Desktop/web/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1349                            
Stack trace:                                                                                               
#0 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illumina  
te\Foundation\Bootstrap\HandleExceptions->handleError()                                                    
#1 /home/brankoo/Desktop/web/vendor/composer/ClassLoader.php(571): include('...')
#2 /home/brankoo/Desktop/web/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#3 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Support/helpers.php(110): Composer\A
utoload\ClassLoader->loadClass()
#4 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(130):
collect()
#5 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(106):
Illuminate\Foundation\PackageManifest->build()
#6 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89):
Illuminate\Foundation\PackageManifest->getManifest()
#7 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78):
Illuminate\Foundation\PackageManifest->config()
#8 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades
.php(26): Illuminate\Foundation\PackageManifest->aliases()
#9 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Ill
uminate\Foundation\Bootstrap\RegisterFacades->bootstrap()
#10 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310):
Illuminate\Foundation\Application->bootstrapWith()
#11 /home/brankoo/Desktop/web/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127):
Illuminate\Foundation\Console\Kernel->bootstrap()
#12 /home/brankoo/Desktop/web/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#13 {main}


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

This is how my composer.json file looks like:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2.5|^8.0",
        "algolia/algoliasearch-client-php": "^2.7",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel-lang/lang": "^7.0",
        "laravel/framework": "^7.24",
        "laravel/scout": "^8.3",
        "laravel/tinker": "^2.0",
        "laravel/ui": "^2.2",
        "laravelcollective/html": "^6.1",
        "spatie/laravel-searchable": "^1.6"
    },
    "require-dev": {
        "facade/ignition": "^2.0",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Already tried recommended solutions in these two topics, none of them worked:

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

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

EDIT: Changing laravel/framework version to ^8.75 did not solve issue as someone flagged this question as duplicate. Instead it outputted new error:

Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- laravel/ui[v2.2.0, ..., v2.4.1] require php ^7.2.5 -> your php version (8.1.5) does not satisfy that requirement.
- illuminate/support[v7.0.0, ..., v7.28.4] require php ^7.2.5 -> your php version (8.1.5) does not satisfythat requirement.
- Only one of these can be installed: illuminate/support[v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev], laravel/framework[v8.75.0, ..., 8.x-dev]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
- laravel/ui[v2.5.0, ..., 2.x-dev] require illuminate/support ^7.0 -> satisfiable by illuminate/support[v7.0.0, ..., 7.x-dev].
- Root composer.json requires laravel/ui ^2.2 -> satisfiable by laravel/ui[v2.2.0, ..., 2.x-dev].
- Root composer.json requires laravel/framework ^8.75 -> satisfiable by laravel/framework[v8.75.0, ..., 8.x-dev].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
r problems
  • 11
  • 1
  • 4
  • i would check the php version you have, perhaps an older php 5 for example – Lk77 Apr 27 '22 at 15:55
  • Laravel 7 isn't compatible with PHP 8.1. It does work with PHP 8.0, as shown by the composer requirements. – aynber Apr 27 '22 at 15:57
  • @aynber composer is using PHP version 8.1.5, but I have installed both - 8.1.5 and 7.3. How can I change what PHP version composer uses? Or how can I just downgrade PHP 8.1 to 8.0? – r problems Apr 27 '22 at 15:59
  • Downgrading will require installing php 8.0 and making sure everything is pointed to the correct version. https://stackoverflow.com/questions/43040685/how-can-i-change-php-cli-version-on-ubuntu-14-04 has instructions on how to change the PHP version on the command line. Just change the version number from what the accepted answer has. – aynber Apr 27 '22 at 16:01
  • @aynber it does not work. Already edited my post and added the output to the bottom. – r problems Apr 27 '22 at 16:03
  • There are a lot more changes to make to your composer if you're upgrading from 7 to 8, which that answer does not address. See https://laravel.com/docs/8.x/upgrade for all of the changes – aynber Apr 27 '22 at 16:06
  • @aynber I am not trying to upgrade anything, I just want to run older Laravel 7.4x project on my laptop – r problems Apr 27 '22 at 16:09
  • Changing the `laravel/framework` to `^8.75` *is* an upgrade. I would suggest running it with PHP 7.4, which my other link addressed for the command line. You'll also need to make sure your web server is using the correct version. – aynber Apr 27 '22 at 16:10
  • @aynber I have installed php73 as well, but my composer is running on 8.1.5 according to `composer diagnose` `PHP version: 8.1.5 PHP binary path: /usr/bin/php`. Did not find a way to change binary path do `/usr/bin/php73` where my PHP 7.3 is installed. I need to run this project only on local machine. – r problems Apr 27 '22 at 16:14

0 Answers0