php artisan: "failed to open stream: No such file or directory"

php artisan: "failed to open stream: No such file or directory"

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

php artisan: "failed to open stream: No such file or directory"

When you run php artisan serve, Laravel expects a specific project structure to be intact, specifically the presence of the vendor directory containing the Composer autoloader. If your terminal displays an error like require(/path/to/project/vendor/autoload.php): failed to open stream: No such file or directory, it is not a bug in the Artisan command itself. It is a clear signal that the project has not been installed via Composer yet, or the installation process was interrupted before dependencies were downloaded.

The core issue lies in the difference between cloning a repository (or creating a new project) and actually installing its dependencies. When you execute laravel new new-blog, Laravel creates the skeleton files: composer.json, artisan, routes/web.php, and the directory structure. However, the actual PHP libraries and frameworks required to run the application are not present immediately. These live in the vendor folder, which is generated only after running composer install.

The error log explicitly points to line 18 in your artisan file:

require __DIR__.'/vendor/autoload.php';

This line attempts to load the autoloader. The autoloader is a script generated by Composer that maps class names to their physical file locations without you needing to write manual include or require statements for every single library. Without this file, PHP does not know where to find the Eloquent ORM, Blade engine, or any other framework component.

To resolve this on your Debian Buster machine, you need to run Composer in the project directory:

cd new-blog
composer install

This command reads the composer.json file and downloads all packages listed under require into a folder named vendor. Once this process completes, you will see the vendor/autoload.php file alongside your other project files. You can then safely run php artisan serve again.

There is a distinct difference between development environments and production setups regarding how you handle this. In a local development environment like yours, running composer install every time you clone or create a project is standard practice. However, in a production deployment scenario, the vendor folder should never be committed to version control systems like Git. Instead, you would use the composer.lock file to ensure dependencies are locked to specific versions and run composer install on the server before starting the web server.

Sometimes, the vendor directory exists but might be empty or corrupted if a previous installation failed mid-process. If running composer install results in permission errors or hangs, check that your current user has write permissions for the project folder:

ls -la vendor

If the directory is missing entirely, ensure you are in the correct working directory before invoking Composer. It is also worth noting that adding $PATH entries for laravel (as mentioned in your setup steps) allows you to run laravel new from anywhere, but it does not affect the internal execution of php artisan. The artisan file always looks relative to its own location for the vendor path.

If you encounter issues where composer install fails due to missing PHP extensions required by specific packages (common on older Debian versions), you may need to update your system libraries or ensure necessary extensions like xml, mbstring, and bcmath are enabled in your php.ini. This is a frequent pitfall when moving from a tutorial guide that assumes a pre-configured environment to a fresh Linux installation.

For further guidance on setting up Laravel environments, including production configurations and dependency management strategies, you can refer to resources such as https://laravelcompany.com.

Our network