0

So I am new to php/laravel and am trying to set up my environment here with composer on opensuse 15.0.

When I try to run php artisan migrate

I get this error:

PHP Warning:  require(/home/mattyo/FirstLaravelProject/matt-project-laravel/vendor/autoload.php): failed to open stream: No such file or directory in /home/mattyo/FirstLaravelProject/matt-project-laravel/artisan on line 18
PHP Fatal error:  require(): Failed opening required '/home/mattyo/FirstLaravelProject/matt-project-laravel/vendor/autoload.php' (include_path='.:/usr/share/php7:/usr/share/php7/PEAR') in /home/mattyo/FirstLaravelProject/matt-project-laravel/artisan on line 18

I get the same error when trying to run php artisan serve.

I have tried to run composer update along with composer install composer update --no-scripts and had no luck.

Any help would be greatly appreciated.

here's my composer.json

    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2.5|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^6.3.1|^7.0.1",
        "laravel/framework": "^7.29",
        "laravel/tinker": "^2.5"
    },
    "require-dev": {
        "facade/ignition": "^2.0",
        "fakerphp/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^4.3",
        "phpunit/phpunit": "^8.5.8|^9.3.3"
    },
    "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"
        ]
    }
}

After running composer global require laravel/installer I received the following error message:

Changed current directory to /home/mattyo/.config/composer
Using version ^3.0 for laravel/installer
./composer.json has been updated
Running composer update laravel/installer
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/installer[v3.0.0, ..., v3.0.1] require ext-zip * -> it is missing from your system. Install or enable PHP's zip extension.
    - laravel/installer[v3.1.0, ..., v3.2.0] require php ^7.2.9 -> your php version (7.2.5) does not satisfy that requirement.
    - Root composer.json requires laravel/installer ^3.0 -> satisfiable by laravel/installer[v3.0.0, v3.0.1, v3.1.0, v3.2.0].

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php7/cli/php.ini
    - /etc/php7/conf.d/ctype.ini
    - /etc/php7/conf.d/dom.ini
    - /etc/php7/conf.d/iconv.ini
    - /etc/php7/conf.d/json.ini
    - /etc/php7/conf.d/mbstring.ini
    - /etc/php7/conf.d/openssl.ini
    - /etc/php7/conf.d/pdo.ini
    - /etc/php7/conf.d/pdo_sqlite.ini
    - /etc/php7/conf.d/phar.ini
    - /etc/php7/conf.d/sqlite3.ini
    - /etc/php7/conf.d/tokenizer.ini
    - /etc/php7/conf.d/xmlreader.ini
    - /etc/php7/conf.d/xmlwriter.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json to its original content.
  • I have php and composer installed and have created the laravel project successfully. I think it should still work with Composer 1.6.5 yet figured would post what I have here so far. – Matthew Overstrom Jan 03 '21 at 19:34
  • "Your requirements could not be resolved to an installable set of packages." is an important hint. Updating Composer should not be needed, but without more details, it's impossible to tell you **why** resolving the dependencies does not work. Also, please remove irrelevant tags - currently, I see no connection between your error and SQLite or Artisan – Nico Haase Jan 04 '21 at 06:26
  • You could start by adding the full error message to your question, or at least the content of `composer.json` – Nico Haase Jan 05 '21 at 15:29
  • I actually got the "Your requirements could not be resolved to an installable set of packages" when I tried to run ```composer update --no-scripts``` will add that to original message now with full details – Matthew Overstrom Jan 05 '21 at 15:53
  • Which is "the other error"? – Nico Haase Jan 05 '21 at 15:55
  • Does https://stackoverflow.com/questions/23771117/requires-ext-fileinfo-how-do-i-add-that-into-my-composer-json-file help? – Nico Haase Jan 05 '21 at 15:55
  • Or does https://stackoverflow.com/questions/24850136/i-have-ext-fileinfo-but-composer-says-it-is-missing/24850235 help? – Nico Haase Jan 05 '21 at 15:56
  • If you cannot run `composer install`, it's obvious that Composer's autoloader is not written. This is what you need to resolve first, as Sameh already pointed out. To get this working, read the answers from the linked questions – Nico Haase Jan 05 '21 at 16:28
  • Thanks Nico give this a try in the AM. – Matthew Overstrom Jan 06 '21 at 03:21

1 Answers1

0

It seems the autoload.php file wasn't created by Composer for some reason. try composer dump-autoload and see if it works by running php artisan in the terminal.

If this issue still exists, remove the ./vendor directory with rm -rf vendor/* and remove composer cache composer clearcache. Then run composer install again

If none of the above solved the problem, Check if the composer.json file contains wrong or missing dependencies.

Sameh Ashraf
  • 112
  • 1
  • 2
  • 8
  • Thanks so much for trying to help here.... I tried everything listed above and it seems to be circling back to this one issue with composer. ```mattyo@linux-tzsv:~/FirstLaravelProject/matt-project-laravel> composer install Loading composer repositories with package information Warning from https://packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2 Updating dependencies (including require-dev) ``` I checked out the composer.json file and it shows ... – Matthew Overstrom Jan 05 '21 at 14:43
  • Try to reinstall composer itself from here https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos – Sameh Ashraf Jan 05 '21 at 14:49
  • Just reinstalled composer .. same issue.. ```mattyo@linux-tzsv:~/FirstLaravelProject/matt-project-laravel> php artisan PHP Warning: require(/home/mattyo/FirstLaravelProject/matt-project-laravel/vendor/autoload.php): failed to open stream: No such file or directory in /home/mattyo/FirstLaravelProject/matt-project-laravel/artisan on line 18``` hmm – Matthew Overstrom Jan 05 '21 at 15:11
  • full composer.json file linked above in original question -- edited **** – Matthew Overstrom Jan 05 '21 at 15:45
  • OK, composer.json looks like mine. Try to reinstall Laravel with Laravel installer. See https://laravel.com/docs/8.x#the-laravel-installer – Sameh Ashraf Jan 05 '21 at 21:04
  • Are you referring to installing the Laravel Installer as a global Composer dependency with "#The Laravel installer" : ? ```composer global require laravel/installer laravel new example-app``` I noticed it said "Make sure to place Composer's system-wide vendor bin directory in your $PATH so the laravel executable can be located by your system"...... I'm using opensuse 15.0 so trying to find where that would be – Matthew Overstrom Jan 06 '21 at 18:09
  • yes, You should put Composer in your path. So, you have two options to do that. The first option, install Composer globally. See https://getcomposer.org/doc/00-intro.md#globally The second option is to install Composer in any directory in your system and add that directory to your path. See https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path – Sameh Ashraf Jan 06 '21 at 19:41
  • So I just tried to install composer globally with the laravel installer ```composer global require laravel/installer``` and the installation failed ... I'll add the error message to post since it's too long.. and will try to add the directory to path to see if that works – Matthew Overstrom Jan 07 '21 at 18:53
  • added the error message from trying to install composer globally to original message.. and just tried installing Composer in any directory in and adding that directory to my path by running ```PATH=$PATH:~/opt/bin``` and still the same error. – Matthew Overstrom Jan 07 '21 at 19:08
  • Check this answer here: https://stackoverflow.com/a/46058582/8619937 I think this will fix it. – Sameh Ashraf Jan 09 '21 at 00:17
  • You may need to update your PHP version to 7.2.9 – Sameh Ashraf Jan 09 '21 at 00:20
  • hm i currenty have PHP version 7.2.5.. Checked out the answer wasn't sure exactly how to get it to 7.2.9-- or if I can use version 3 instead with ```sudo apt-get install php7.3-zip ``` ------ do you know how I would get the version you mentioned 7.2.9 or if I should just get PHP v3 and give that a try? – Matthew Overstrom Jan 11 '21 at 02:55
  • ```sudo apt install php-zip7.3-zip``` does't work but ```sudo apt install php-zip``` went through yet only for 7.2.5.... I'm starting to wonder if downloading composer through the opensuse direct site caused this issue.. should I give another command a try? no one else is using opensuse but hoping we can still get this to work – Matthew Overstrom Jan 11 '21 at 03:15
  • So I got it working on windows. Still an error here with my linux- opensuse. @Sameh I might just start from the beginning here and see what happens – Matthew Overstrom Jan 20 '21 at 21:36