Composer PSR-4 autoloading “class not found” debug
up vote
2
down vote
favorite
Yes another question about the "class not found" error. Either I am missing something, or I misunderstood the PSR-4 logic.
My composer library directory sturcture:
"Scanner" => "src" => "Test.php"
Test.php
namespace MyNS;
class Test
{
}
composer.json
"autoload": {
"psr-4": {
"MyNS\": "src/"
},
}
So, now I load the library in my project with composer and try using it.
require_once("../vendor/autoload.php");
$test = new MyNSTest();
Which always results in
"Fatal error: Uncaught Error: Class 'MyNSTest' not found."
. What am I missing? I am staring at this for days now. I have changed folders, I have changed folder names, I have changed uppper to lower and vise versa. Nothing seems to work.
I am using PHP 7.2.2 and Composer version 1.2.2
Even tried this:
require_once("../vendor/autoload.php");
use MyNSTest;
$scanner = new Test();
Update
I debugt the Composer ClassLoader.php file (findFileWithExtension($class, $ext)) method and apparently my files are never loaded because I get put an echo "Done" and a die(); at the end of this method which means the file is not found and thus not loaded. What is wrong with my composer.json?
{
"name": "test/test",
"type": "library",
"description": "",
"keywords": ["php"],
"homepage": "",
"license": "MIT",
"authors": [
{
"name": "",
"email": "",
"homepage": "",
"role": ""
}
],
"require": {
"php": ">=7.2.2"
},
"autoload": {
"psr-4": {
"MyNS\": "src/"
}
}
}
php composer-php autoloader psr-4
|
show 3 more comments
up vote
2
down vote
favorite
Yes another question about the "class not found" error. Either I am missing something, or I misunderstood the PSR-4 logic.
My composer library directory sturcture:
"Scanner" => "src" => "Test.php"
Test.php
namespace MyNS;
class Test
{
}
composer.json
"autoload": {
"psr-4": {
"MyNS\": "src/"
},
}
So, now I load the library in my project with composer and try using it.
require_once("../vendor/autoload.php");
$test = new MyNSTest();
Which always results in
"Fatal error: Uncaught Error: Class 'MyNSTest' not found."
. What am I missing? I am staring at this for days now. I have changed folders, I have changed folder names, I have changed uppper to lower and vise versa. Nothing seems to work.
I am using PHP 7.2.2 and Composer version 1.2.2
Even tried this:
require_once("../vendor/autoload.php");
use MyNSTest;
$scanner = new Test();
Update
I debugt the Composer ClassLoader.php file (findFileWithExtension($class, $ext)) method and apparently my files are never loaded because I get put an echo "Done" and a die(); at the end of this method which means the file is not found and thus not loaded. What is wrong with my composer.json?
{
"name": "test/test",
"type": "library",
"description": "",
"keywords": ["php"],
"homepage": "",
"license": "MIT",
"authors": [
{
"name": "",
"email": "",
"homepage": "",
"role": ""
}
],
"require": {
"php": ">=7.2.2"
},
"autoload": {
"psr-4": {
"MyNS\": "src/"
}
}
}
php composer-php autoloader psr-4
Looking at the provided namespace, your path should besrc/PSR4/
and notsrc/
and the namespace of classTest
isMyNSPSR4
and notMyNS
alone.
– revo
Nov 18 at 8:01
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tackt. Still not working.
– Digital Human
Nov 18 at 8:11
Did you docomposer dump-autoload
after making changes?
– revo
Nov 18 at 8:14
It feels like that the autoloader isn't working at all. It doesn't seem to make a difference what names I use, what folders I use. I tried removing namespaces in both the classes and the composer.json. Even that didn't work. It still returns 'Class not found'.
– Digital Human
Nov 18 at 8:17
@revo yes everytime. Is there a way to debug what 'autoload' is exactly doing? In what folder it looks for what files for example?
– Digital Human
Nov 18 at 8:26
|
show 3 more comments
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Yes another question about the "class not found" error. Either I am missing something, or I misunderstood the PSR-4 logic.
My composer library directory sturcture:
"Scanner" => "src" => "Test.php"
Test.php
namespace MyNS;
class Test
{
}
composer.json
"autoload": {
"psr-4": {
"MyNS\": "src/"
},
}
So, now I load the library in my project with composer and try using it.
require_once("../vendor/autoload.php");
$test = new MyNSTest();
Which always results in
"Fatal error: Uncaught Error: Class 'MyNSTest' not found."
. What am I missing? I am staring at this for days now. I have changed folders, I have changed folder names, I have changed uppper to lower and vise versa. Nothing seems to work.
I am using PHP 7.2.2 and Composer version 1.2.2
Even tried this:
require_once("../vendor/autoload.php");
use MyNSTest;
$scanner = new Test();
Update
I debugt the Composer ClassLoader.php file (findFileWithExtension($class, $ext)) method and apparently my files are never loaded because I get put an echo "Done" and a die(); at the end of this method which means the file is not found and thus not loaded. What is wrong with my composer.json?
{
"name": "test/test",
"type": "library",
"description": "",
"keywords": ["php"],
"homepage": "",
"license": "MIT",
"authors": [
{
"name": "",
"email": "",
"homepage": "",
"role": ""
}
],
"require": {
"php": ">=7.2.2"
},
"autoload": {
"psr-4": {
"MyNS\": "src/"
}
}
}
php composer-php autoloader psr-4
Yes another question about the "class not found" error. Either I am missing something, or I misunderstood the PSR-4 logic.
My composer library directory sturcture:
"Scanner" => "src" => "Test.php"
Test.php
namespace MyNS;
class Test
{
}
composer.json
"autoload": {
"psr-4": {
"MyNS\": "src/"
},
}
So, now I load the library in my project with composer and try using it.
require_once("../vendor/autoload.php");
$test = new MyNSTest();
Which always results in
"Fatal error: Uncaught Error: Class 'MyNSTest' not found."
. What am I missing? I am staring at this for days now. I have changed folders, I have changed folder names, I have changed uppper to lower and vise versa. Nothing seems to work.
I am using PHP 7.2.2 and Composer version 1.2.2
Even tried this:
require_once("../vendor/autoload.php");
use MyNSTest;
$scanner = new Test();
Update
I debugt the Composer ClassLoader.php file (findFileWithExtension($class, $ext)) method and apparently my files are never loaded because I get put an echo "Done" and a die(); at the end of this method which means the file is not found and thus not loaded. What is wrong with my composer.json?
{
"name": "test/test",
"type": "library",
"description": "",
"keywords": ["php"],
"homepage": "",
"license": "MIT",
"authors": [
{
"name": "",
"email": "",
"homepage": "",
"role": ""
}
],
"require": {
"php": ">=7.2.2"
},
"autoload": {
"psr-4": {
"MyNS\": "src/"
}
}
}
php composer-php autoloader psr-4
php composer-php autoloader psr-4
edited Nov 18 at 16:31
asked Nov 18 at 7:56
Digital Human
569620
569620
Looking at the provided namespace, your path should besrc/PSR4/
and notsrc/
and the namespace of classTest
isMyNSPSR4
and notMyNS
alone.
– revo
Nov 18 at 8:01
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tackt. Still not working.
– Digital Human
Nov 18 at 8:11
Did you docomposer dump-autoload
after making changes?
– revo
Nov 18 at 8:14
It feels like that the autoloader isn't working at all. It doesn't seem to make a difference what names I use, what folders I use. I tried removing namespaces in both the classes and the composer.json. Even that didn't work. It still returns 'Class not found'.
– Digital Human
Nov 18 at 8:17
@revo yes everytime. Is there a way to debug what 'autoload' is exactly doing? In what folder it looks for what files for example?
– Digital Human
Nov 18 at 8:26
|
show 3 more comments
Looking at the provided namespace, your path should besrc/PSR4/
and notsrc/
and the namespace of classTest
isMyNSPSR4
and notMyNS
alone.
– revo
Nov 18 at 8:01
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tackt. Still not working.
– Digital Human
Nov 18 at 8:11
Did you docomposer dump-autoload
after making changes?
– revo
Nov 18 at 8:14
It feels like that the autoloader isn't working at all. It doesn't seem to make a difference what names I use, what folders I use. I tried removing namespaces in both the classes and the composer.json. Even that didn't work. It still returns 'Class not found'.
– Digital Human
Nov 18 at 8:17
@revo yes everytime. Is there a way to debug what 'autoload' is exactly doing? In what folder it looks for what files for example?
– Digital Human
Nov 18 at 8:26
Looking at the provided namespace, your path should be
src/PSR4/
and not src/
and the namespace of class Test
is MyNSPSR4
and not MyNS
alone.– revo
Nov 18 at 8:01
Looking at the provided namespace, your path should be
src/PSR4/
and not src/
and the namespace of class Test
is MyNSPSR4
and not MyNS
alone.– revo
Nov 18 at 8:01
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tackt. Still not working.
– Digital Human
Nov 18 at 8:11
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tackt. Still not working.
– Digital Human
Nov 18 at 8:11
Did you do
composer dump-autoload
after making changes?– revo
Nov 18 at 8:14
Did you do
composer dump-autoload
after making changes?– revo
Nov 18 at 8:14
It feels like that the autoloader isn't working at all. It doesn't seem to make a difference what names I use, what folders I use. I tried removing namespaces in both the classes and the composer.json. Even that didn't work. It still returns 'Class not found'.
– Digital Human
Nov 18 at 8:17
It feels like that the autoloader isn't working at all. It doesn't seem to make a difference what names I use, what folders I use. I tried removing namespaces in both the classes and the composer.json. Even that didn't work. It still returns 'Class not found'.
– Digital Human
Nov 18 at 8:17
@revo yes everytime. Is there a way to debug what 'autoload' is exactly doing? In what folder it looks for what files for example?
– Digital Human
Nov 18 at 8:26
@revo yes everytime. Is there a way to debug what 'autoload' is exactly doing? In what folder it looks for what files for example?
– Digital Human
Nov 18 at 8:26
|
show 3 more comments
2 Answers
2
active
oldest
votes
up vote
0
down vote
i think the problem is in your namespace declaration
you calling the class from MyNS
but class namespace is namespace MyNSPSR4;
require_once("../vendor/autoload.php");
$test = new MyNSTest();
// it should be new MyNSPSR4Test();
and make sure, your class file in same directory which you mentioned in composer autoload
file
also you have to run dump-autoload
command for any change in classnames
you can visit for this autoload feature
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tact. Still not working.
– Digital Human
Nov 18 at 8:13
after changing namespace did you run dump-autoload ? more details: getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
– Emtiaz Zahid
Nov 18 at 8:37
add a comment |
up vote
0
down vote
To debug what is happening open ClassLoader.php
file then go where findFileWithExtension()
method is defined to add an echo
statement:
# vendor/composer/ClassLoader.php:386
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
// Add this line
echo $file, PHP_EOL;
}
Do not do composer dumpautoload
after you manually modified above file until we are done.
Now by executing your PHP file you will see something similar to this at the very beginning of output:
path/to/project/vendor/composer/../../src/Test.php
Which is:
path/to/project/src/Test.php
So this is the file that composer is looking for and should contain something like this:
namespace MyNS;
class Test { }
If there is an issue in including the file then it means you have to care about three things:
- Path and filename
- Namespace used in file
- Class name used in file (class name should be the same as filename)
Thanks! I will do some testing later today. I'll keep you guys posted :)
– Digital Human
Nov 18 at 10:06
0 (zero) output. As my gut feeling said. It doesn't do anything with the psr-4 autoload.
– Digital Human
Nov 18 at 16:19
So it never gets loaded by PSR-4. That is the conclusion. I debuged the entire findFileWithExtenson($class, $ext) method in the ClassLoader.php and it reaches the end of the method.
– Digital Human
Nov 18 at 16:28
Please open upautoload_psr4.php
and see the contents. Do you see a line corresponding toMyNS
?
– revo
Nov 18 at 18:09
No I don't see anything except this: ` $vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir); return array( ); `
– Digital Human
Nov 19 at 7:12
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
i think the problem is in your namespace declaration
you calling the class from MyNS
but class namespace is namespace MyNSPSR4;
require_once("../vendor/autoload.php");
$test = new MyNSTest();
// it should be new MyNSPSR4Test();
and make sure, your class file in same directory which you mentioned in composer autoload
file
also you have to run dump-autoload
command for any change in classnames
you can visit for this autoload feature
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tact. Still not working.
– Digital Human
Nov 18 at 8:13
after changing namespace did you run dump-autoload ? more details: getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
– Emtiaz Zahid
Nov 18 at 8:37
add a comment |
up vote
0
down vote
i think the problem is in your namespace declaration
you calling the class from MyNS
but class namespace is namespace MyNSPSR4;
require_once("../vendor/autoload.php");
$test = new MyNSTest();
// it should be new MyNSPSR4Test();
and make sure, your class file in same directory which you mentioned in composer autoload
file
also you have to run dump-autoload
command for any change in classnames
you can visit for this autoload feature
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tact. Still not working.
– Digital Human
Nov 18 at 8:13
after changing namespace did you run dump-autoload ? more details: getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
– Emtiaz Zahid
Nov 18 at 8:37
add a comment |
up vote
0
down vote
up vote
0
down vote
i think the problem is in your namespace declaration
you calling the class from MyNS
but class namespace is namespace MyNSPSR4;
require_once("../vendor/autoload.php");
$test = new MyNSTest();
// it should be new MyNSPSR4Test();
and make sure, your class file in same directory which you mentioned in composer autoload
file
also you have to run dump-autoload
command for any change in classnames
you can visit for this autoload feature
i think the problem is in your namespace declaration
you calling the class from MyNS
but class namespace is namespace MyNSPSR4;
require_once("../vendor/autoload.php");
$test = new MyNSTest();
// it should be new MyNSPSR4Test();
and make sure, your class file in same directory which you mentioned in composer autoload
file
also you have to run dump-autoload
command for any change in classnames
you can visit for this autoload feature
edited Nov 18 at 8:38
answered Nov 18 at 8:02
Emtiaz Zahid
897515
897515
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tact. Still not working.
– Digital Human
Nov 18 at 8:13
after changing namespace did you run dump-autoload ? more details: getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
– Emtiaz Zahid
Nov 18 at 8:37
add a comment |
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tact. Still not working.
– Digital Human
Nov 18 at 8:13
after changing namespace did you run dump-autoload ? more details: getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
– Emtiaz Zahid
Nov 18 at 8:37
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tact. Still not working.
– Digital Human
Nov 18 at 8:13
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tact. Still not working.
– Digital Human
Nov 18 at 8:13
after changing namespace did you run dump-autoload ? more details: getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
– Emtiaz Zahid
Nov 18 at 8:37
after changing namespace did you run dump-autoload ? more details: getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
– Emtiaz Zahid
Nov 18 at 8:37
add a comment |
up vote
0
down vote
To debug what is happening open ClassLoader.php
file then go where findFileWithExtension()
method is defined to add an echo
statement:
# vendor/composer/ClassLoader.php:386
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
// Add this line
echo $file, PHP_EOL;
}
Do not do composer dumpautoload
after you manually modified above file until we are done.
Now by executing your PHP file you will see something similar to this at the very beginning of output:
path/to/project/vendor/composer/../../src/Test.php
Which is:
path/to/project/src/Test.php
So this is the file that composer is looking for and should contain something like this:
namespace MyNS;
class Test { }
If there is an issue in including the file then it means you have to care about three things:
- Path and filename
- Namespace used in file
- Class name used in file (class name should be the same as filename)
Thanks! I will do some testing later today. I'll keep you guys posted :)
– Digital Human
Nov 18 at 10:06
0 (zero) output. As my gut feeling said. It doesn't do anything with the psr-4 autoload.
– Digital Human
Nov 18 at 16:19
So it never gets loaded by PSR-4. That is the conclusion. I debuged the entire findFileWithExtenson($class, $ext) method in the ClassLoader.php and it reaches the end of the method.
– Digital Human
Nov 18 at 16:28
Please open upautoload_psr4.php
and see the contents. Do you see a line corresponding toMyNS
?
– revo
Nov 18 at 18:09
No I don't see anything except this: ` $vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir); return array( ); `
– Digital Human
Nov 19 at 7:12
add a comment |
up vote
0
down vote
To debug what is happening open ClassLoader.php
file then go where findFileWithExtension()
method is defined to add an echo
statement:
# vendor/composer/ClassLoader.php:386
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
// Add this line
echo $file, PHP_EOL;
}
Do not do composer dumpautoload
after you manually modified above file until we are done.
Now by executing your PHP file you will see something similar to this at the very beginning of output:
path/to/project/vendor/composer/../../src/Test.php
Which is:
path/to/project/src/Test.php
So this is the file that composer is looking for and should contain something like this:
namespace MyNS;
class Test { }
If there is an issue in including the file then it means you have to care about three things:
- Path and filename
- Namespace used in file
- Class name used in file (class name should be the same as filename)
Thanks! I will do some testing later today. I'll keep you guys posted :)
– Digital Human
Nov 18 at 10:06
0 (zero) output. As my gut feeling said. It doesn't do anything with the psr-4 autoload.
– Digital Human
Nov 18 at 16:19
So it never gets loaded by PSR-4. That is the conclusion. I debuged the entire findFileWithExtenson($class, $ext) method in the ClassLoader.php and it reaches the end of the method.
– Digital Human
Nov 18 at 16:28
Please open upautoload_psr4.php
and see the contents. Do you see a line corresponding toMyNS
?
– revo
Nov 18 at 18:09
No I don't see anything except this: ` $vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir); return array( ); `
– Digital Human
Nov 19 at 7:12
add a comment |
up vote
0
down vote
up vote
0
down vote
To debug what is happening open ClassLoader.php
file then go where findFileWithExtension()
method is defined to add an echo
statement:
# vendor/composer/ClassLoader.php:386
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
// Add this line
echo $file, PHP_EOL;
}
Do not do composer dumpautoload
after you manually modified above file until we are done.
Now by executing your PHP file you will see something similar to this at the very beginning of output:
path/to/project/vendor/composer/../../src/Test.php
Which is:
path/to/project/src/Test.php
So this is the file that composer is looking for and should contain something like this:
namespace MyNS;
class Test { }
If there is an issue in including the file then it means you have to care about three things:
- Path and filename
- Namespace used in file
- Class name used in file (class name should be the same as filename)
To debug what is happening open ClassLoader.php
file then go where findFileWithExtension()
method is defined to add an echo
statement:
# vendor/composer/ClassLoader.php:386
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
// Add this line
echo $file, PHP_EOL;
}
Do not do composer dumpautoload
after you manually modified above file until we are done.
Now by executing your PHP file you will see something similar to this at the very beginning of output:
path/to/project/vendor/composer/../../src/Test.php
Which is:
path/to/project/src/Test.php
So this is the file that composer is looking for and should contain something like this:
namespace MyNS;
class Test { }
If there is an issue in including the file then it means you have to care about three things:
- Path and filename
- Namespace used in file
- Class name used in file (class name should be the same as filename)
edited Nov 18 at 9:27
answered Nov 18 at 9:22
revo
31.4k124679
31.4k124679
Thanks! I will do some testing later today. I'll keep you guys posted :)
– Digital Human
Nov 18 at 10:06
0 (zero) output. As my gut feeling said. It doesn't do anything with the psr-4 autoload.
– Digital Human
Nov 18 at 16:19
So it never gets loaded by PSR-4. That is the conclusion. I debuged the entire findFileWithExtenson($class, $ext) method in the ClassLoader.php and it reaches the end of the method.
– Digital Human
Nov 18 at 16:28
Please open upautoload_psr4.php
and see the contents. Do you see a line corresponding toMyNS
?
– revo
Nov 18 at 18:09
No I don't see anything except this: ` $vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir); return array( ); `
– Digital Human
Nov 19 at 7:12
add a comment |
Thanks! I will do some testing later today. I'll keep you guys posted :)
– Digital Human
Nov 18 at 10:06
0 (zero) output. As my gut feeling said. It doesn't do anything with the psr-4 autoload.
– Digital Human
Nov 18 at 16:19
So it never gets loaded by PSR-4. That is the conclusion. I debuged the entire findFileWithExtenson($class, $ext) method in the ClassLoader.php and it reaches the end of the method.
– Digital Human
Nov 18 at 16:28
Please open upautoload_psr4.php
and see the contents. Do you see a line corresponding toMyNS
?
– revo
Nov 18 at 18:09
No I don't see anything except this: ` $vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir); return array( ); `
– Digital Human
Nov 19 at 7:12
Thanks! I will do some testing later today. I'll keep you guys posted :)
– Digital Human
Nov 18 at 10:06
Thanks! I will do some testing later today. I'll keep you guys posted :)
– Digital Human
Nov 18 at 10:06
0 (zero) output. As my gut feeling said. It doesn't do anything with the psr-4 autoload.
– Digital Human
Nov 18 at 16:19
0 (zero) output. As my gut feeling said. It doesn't do anything with the psr-4 autoload.
– Digital Human
Nov 18 at 16:19
So it never gets loaded by PSR-4. That is the conclusion. I debuged the entire findFileWithExtenson($class, $ext) method in the ClassLoader.php and it reaches the end of the method.
– Digital Human
Nov 18 at 16:28
So it never gets loaded by PSR-4. That is the conclusion. I debuged the entire findFileWithExtenson($class, $ext) method in the ClassLoader.php and it reaches the end of the method.
– Digital Human
Nov 18 at 16:28
Please open up
autoload_psr4.php
and see the contents. Do you see a line corresponding to MyNS
?– revo
Nov 18 at 18:09
Please open up
autoload_psr4.php
and see the contents. Do you see a line corresponding to MyNS
?– revo
Nov 18 at 18:09
No I don't see anything except this: ` $vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir); return array( ); `
– Digital Human
Nov 19 at 7:12
No I don't see anything except this: ` $vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir); return array( ); `
– Digital Human
Nov 19 at 7:12
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53358919%2fcomposer-psr-4-autoloading-class-not-found-debug%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Looking at the provided namespace, your path should be
src/PSR4/
and notsrc/
and the namespace of classTest
isMyNSPSR4
and notMyNS
alone.– revo
Nov 18 at 8:01
I removed PSR4 in the namespace (as mentioned) . Not working. I also moved Test.php to folder src/PSR4 and left namespace in tackt. Still not working.
– Digital Human
Nov 18 at 8:11
Did you do
composer dump-autoload
after making changes?– revo
Nov 18 at 8:14
It feels like that the autoloader isn't working at all. It doesn't seem to make a difference what names I use, what folders I use. I tried removing namespaces in both the classes and the composer.json. Even that didn't work. It still returns 'Class not found'.
– Digital Human
Nov 18 at 8:17
@revo yes everytime. Is there a way to debug what 'autoload' is exactly doing? In what folder it looks for what files for example?
– Digital Human
Nov 18 at 8:26