'Class in autoloaded file not recognized
The class definition of \MyOrganization\OurLibrary\Application
isn't recognized in a script in a framework package that uses the core library. It is recognized in an exact copy of the script in the core folder. What is the problem, and how do I resolve it?
library/core/Application.php
namespace MyOrganization\OurLibrary;
class Application {
public static function someMethod() ...
}
library/core/composer.json
{
"name": "myorganization/core",
"type": "library",
"config": { "secure-http": false },
"require": { ... }
"require-dev": { ... }
"autoload": {
"files": ["Application.php"],
}
}
library/framework/composer.json
{
"name": "myorganization/framework",
"type": "library",
"require": {
"myorganization/core": "dev-master",
...
},
"require-dev": { ... }
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"repositories": [
{
"type": "path",
"url": "../core",
"options": { "symlink": true }
}
]
}
library/(core|framework)/script.php
require __DIR__.'/vendor/autoload.php';
\MyOrganization\OurLibrary\Application::someMethod();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|