Question

I'm implementing some classes and I always end up with the following error:

PHP Fatal error:  Class 'Foo\Bar\Filter' not found in /blabla/filterTest.php on line 10

I have a test like this (filterTest.php):

<?php

namespace Foo\Tests\Bar\FilterTest;

use Foo\Bar\Filter;

class FilterTest extends \PHPUnit_Framework_TestCase {

    public function testSth() {
        new Filter;
    }
}

And a Filter class like the following (filter.php):

<?php

namespace Foo\Bar;

class Filter {

    public function __construct() {
        echo 'foo';
    }
}

Any ideas? o.O

Was it helpful?

Solution

The solution was as easy as including the file where the class I needed was...

For those as like me didn't know that, you need to include the file. Namespacing won't do it for you ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top