with composer create-project laravel/laravel project-name
failing with an error.
Generating optimized autoload files
> IlluminateFoundationComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Warning: require(/Documents/project-name/vendor/autoload.php): Failed to open stream: No such file or directory in /Documents/project-name/artisan on line 9
PHP Fatal error: Uncaught Error: Failed opening required '/Documents/project-name/vendor/autoload.php' (include_path='.:/usr/share/php') in /Documents/project-name/artisan:9
Stack trace:
#0 {main}
thrown in /Documents/project-name/artisan on line 9
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
I ensured I had permission for user groups and read/write access.
PHP version 8.3
Composer 2.7.4
Ubuntu system and Apache Server configured
2
Answers
Well, I found the problem.
When executing the composer to create the project, it wasn't able to create the vendor folder even though it had the correct user roles and read/write permissions.
Then, I did what always worked: I ran the command with sudo, and the vendor folder was created successfully.
After this success, I realized I didn't install Composer using the same process I always use for server setup.
So, I followed the instructions https://getcomposer.org, and everything worked.
Make sure your Composer and PHP installations are working correctly. You can check this by running:
also double-check filesystem permissions
also you might try to clear composer cache
In general I would recommend to make sure that composer’s part works well,
try
composer install
in that folder or in nested folder