Home Ask Login Register

Developers Planet

Your answer is one click away!

Rob February 2016

Class not found - PSR-4 namespaced autoloading

I wanted to set up PSR-4 autoloading for a class I wrote. However I keep getting the error Fatal error: Class 'Glowdemon1\Translxtor\LangParserXML' not found in C:\xampp\htdocs\translator\index.php on line 5

Folder structure(can't post img yet):

enter image description here


namespace Glowdemon1\Translxtor;
class LangParserXML extends ErrorHandler implements ParserInterface{


$translator = new Glowdemon1\Translxtor\LangParserXML('nl.xml');


    "autoload": {
        "psr-4": {
            "Glowdemon1\\": "src/"


return array(
    'Glowdemon1\\' => array($baseDir . '/src'),

I have looked trough countless posts, yet no solutions. This is also posted on https://github.com/glowdemon1/translxtor in case you want a deeper look. Thanks.


byoigres February 2016

I think you should have a Translxtor folder within src containing LangParserXML.class.php and Translator.class.php:

The contiguous sub-namespace names after the "namespace prefix" correspond to a subdirectory within a "base directory", in which the namespace separators represent directory separators. The subdirectory name MUST match the case of the sub-namespace names.

Source: http://www.php-fig.org/psr/psr-4/ `

chalasr February 2016

Updates your composer.json to :

"autoload": {
    "psr-4": {
        "Glowdemon1\\Translxtor\\": "src/"

Or add a src/Transxtor/ directory before your LangParserXMl

Also, your filename cannot contain ".class". It should just be called LangParserXML.php.

Post Status

Asked in February 2016
Viewed 3,448 times
Voted 5
Answered 2 times


Leave an answer

Quote of the day: live life