Search code examples
doctrine-ormcomposer-phpautoloader

Composer/Doctrine 2 Class 'ComposerAutoloaderInit...' not found in vendor/autoload.php


This is driving me insane. Everything was moving along fine until I tried to change my composer.json file. Once I composer.update'ed I started getting this error in my log:

PHP Fatal error:  Class 'ComposerAutoloaderInite904d9fc0cad6e1b28066897f772cc3f' not found in /home/apache2/htdocs/doctrine/vendor/autoload.php on line 7

I've changed composer.json back to the normal state and even went so far as to delete the entire directory and start over again. Absolutely nothing works.

Here's the autoload.php file.

<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInite904d9fc0cad6e1b28066897f772cc3f::getLoader();

UPDATE:

I am using Adobe Dreamweaver locally to edit files on a remote Linux server.

I have recognized a pattern. I get this class error ONLY when I update a file that sits outside of my /src folder. For example, if I update src/Form.php, everything is fine on upload. If I update admin/access/formbuilder.php I get the Class error until I composer dump-autoload.

I just tried adding "admin/access/ to autoload in composer.json but that does not do the trick. Here is what the composer.json file looks like:

{
  "require": {
      "doctrine/orm": "2.4.*",
      "symfony/yaml": "2.*"
  },
  "autoload": {
      "classmap":["src/", "admin/access/"]
  }
}

Solution

  • You are not supposed to provide that file (you mention that file is taken from a tutorial). This is automatically generated by Composer as part of the update process, and gets also generated during install. The name of the class is dynamically generated, and you will never match the current autoloader class name.

    If you somehow committed that file in your own source control, then you should get rid of it. Don't use code that restores that file to a previous state.