require(vendor/autoload.php): failed to open stream

require(vendor/autoload.php): failed to open stream

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

Stefan Bogdanescu

Founder & Senior Architect

require(vendor/autoload.php): failed to open stream

When you encounter a Fatal error: require(): Failed opening required 'vendor/autoload.php', the immediate instinct is often to check your installation paths or re-run Composer. In many cases, that approach works. However, when the error persists despite having successfully installed packages via composer require, it usually points to a specific misunderstanding of where Composer looks for dependencies versus where your application expects them to live.

The error message provided in your logs explicitly states the file is missing at C:\xampp\htdocs\site_web\send_mail.php. This path indicates that your script resides within the XAMPP root directory, and it is attempting to load the autoloader from a sibling or subdirectory relative to itself. The command composer require phpmailer/phpmailer successfully installs dependencies into a vendor folder, but only in the specific directory where you executed the command.

If you ran that command at the project root (e.g., C:\xampp\htdocs\site_web), the autoloader should indeed exist at C:\xampp\htdocs\site_web\vendor\autoload.php. The confusion often arises because users find an unrelated file elsewhere on their machine, such as the one located in C:\Windows\SysWOW64\vendor\autoload.php. This path is irrelevant to your PHP application. That directory contains system-level tools or legacy installer scripts, not your project's dependencies. Relying on a search like dir /s autoload.php can be misleading because it returns every instance of that filename in your OS, leading you to believe the file is accessible when it is actually located in a completely different context.

The core issue here is almost certainly a mismatch between your working directory and the location where Composer installed the files. If you navigated to C:\xampp\htdocs\site_web before running composer require, the vendor directory was created there. However, if the script failing is trying to load it from a different base path, or if that vendor directory was deleted and recreated elsewhere, the stream opens fail.

To resolve this, you must ensure two things: first, that the vendor folder exists at the exact relative path your require statement expects; second, that you are running Composer commands from the correct project root. If you recently moved your project or cloned it into a new location, you cannot simply assume the vendor folder has migrated with you.

You can verify the current state of your installation by navigating to the project root in your terminal and listing the contents. On Windows, use:

cd C:\xampp\htdocs\site_web
dir

Look specifically for the vendor directory in the output. If it is missing, you must run the dependency installer again from within that exact folder:

composer require phpmailer/phpmailer

If the file exists but the error persists, inspect your send_mail.php. Ensure there are no typos in the path or that you haven't accidentally created a symbolic link that points to the wrong location. A common pitfall involves running Composer from within the vendor folder itself. If your current directory is C:\xampp\htdocs\site_web\vendor, and you run composer require phpmailer/phpmailer there, the dependencies will be installed inside vendor\vendor. Your application code then tries to load vendor/autoload.php, which only exists at that deeper level, causing the "No such file or directory" error relative to your project root.

Always run Composer from the project's root directory, not inside any subdirectory or the vendor folder itself. This ensures the autoloader is placed exactly where Laravel, Symfony, or vanilla PHP applications expect it to be. If you are moving between environments, remember that Composer never installs dependencies globally by default; they remain local to the project unless explicitly configured otherwise.

Our network