1
0
mirror of https://github.com/danog/class-finder.git synced 2024-12-02 09:27:48 +01:00
class-finder/docs/exceptions/unknownNamespace.md

40 lines
966 B
Markdown
Raw Normal View History

2018-09-16 19:34:30 +02:00
Unknown Namespace
-----------------
__This exception only occurs in versions 0.3.x and lower.__
2018-09-16 19:34:30 +02:00
Example PHP:
```
<?php
require_once __DIR__ . '/../vendor/autoload.php';
2020-10-11 18:24:12 +02:00
use danog\ClassFinder\ClassFinder;
2018-09-16 19:34:30 +02:00
$classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar');
```
Example `composer.json`:
```
{
"autoload": {
"psr-4": {
"Acme\\": "src/",
},
}
}
```
Results in this exception:
> Unknown namespace 'Acme\Foo\Bar'
This exception occurs when the provided namespace isn't declared or isn't accessible based on items are _are_ declared
in `composer.json`. In the given example, `Acme` is declared to map to `src/` in `composer.json`, so PSR4 would mandate
that `src/Foo/Bar` is a valid path for a directory. However, that directory could not be located, and therefore the
provided namespace is unknown.
If you discover that this exception is raised and Composer _can_ autoload classes found in the namespace, please submit
an issue.