Grigory Ilizirov
Grigory Ilizirov

Reputation: 1028

compser psr-4 autoloading

My composer.json looks like that:

 "autoload": {
        "psr-4": {
            "NamespaceA\\": "src/NamespaceA",
            "NamespaceB\\NamespaceC\\": "src/NamespaceB/NamespaceC",
            "NamespaceD\\": "src/NamespaceD",
            "Testers\\": "test/Testers",
            "NamespaceE\\": "src/NamespaceE",
            "NamespaceF\\": "src/NamespaceF",
            "NamespaceG\\": "src/NamespaceG",

        }
    }

The structure of the namespace is identical to the directories structure inside src.

Is there a way to make the autoload section shorter in this case ?

Upvotes: 0

Views: 53

Answers (1)

R Picheta
R Picheta

Reputation: 660

Maybe try use global namespace above all concrete namespaces e.g. App ? So you can use e.g. App\NamespaceA in your code

"autoload" : {
  "psr-4": {
    "App\\": "src"
  }
}

Upvotes: 1

Related Questions