Skip to content

Upgrading to 3.5.10 has broken function of "autoload" #129

AlexChesser opened this Issue Jan 20, 2011 · 2 comments

2 participants


I just upgraded my PHPUnit from 3.4.15 to 3.5.10 and have found that the existing bootstraps have stopped functioning because __autoload is no longer functioning.

A blog post I found says this is the solution:
This is the previous method of autoloading class.
if (!function_exists('__autoload')) {

function __autoload($class) {

    $file = str_replace('_','/',$class.'.php');

    //Suppress errors in case it can't find the file.
    @include_once $file;



Now here is the new version that works for PHPUnit 3.5
function autoload($class) {
$file = str_replace('_','/',$class.'.php');
include_once $file;
} catch (Exception $e) {



However, I don't think I'll be able to change our legacy applications' autoloader. Is there any way I can change PHPUnit to function the way it used to? Should I roll back to 3.4.x ?


Did you bother to read the release notes for PHPUnit 3.5? They clearly state

  • PHPUnit now uses an autoloader to load its classes. If the tested code requires an autoloader, use spl_autoload_register() to register it.

The only change required is to add spl_autoload_register('__autoload') in your bootstrap script.


Sorry Sebastian. I turned to google for the answer before looking to your documentation. How embarrassing for me. Lesson leaned. Thanks for pointing me to the answer.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.