I'm trying to structure a project so that some code that is auto generated is in a sub folder generated/, but it has the same namespace as files in the parent directory.
For example I have this structure which is giving me the error PHP Fatal error: Uncaught Error: Class 'MyProject\Foo' not found.
Is it possible to have the same namespace for 2 different files in different folders like this?
--lib/
----Foo.php
----generated/
----generated/Bar.php
lib/Foo.php
<?php
namespace MyProject;
class Foo {
...
}
lib/generated/Bar.php
<?php
namespace MyProject;
class Bar {
public function __construct() {
$foo = new Foo();
}
}
My autoload section looks like this:
"autoload": {
"psr-4": {
"MyProject\\" : "lib/"
}
},