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
2020-10-11 18:24:12 +02:00

966 B

Unknown Namespace

This exception only occurs in versions 0.3.x and lower.

Example PHP:

<?php

require_once __DIR__ . '/../vendor/autoload.php';

use danog\ClassFinder\ClassFinder;

$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.