4

I have the following structure

application:
    controllers:
        - SomeController.php
        - SomeOtherController.php

public:
    - index.php

I am including certain packages using composer. I would like to find a way to autoload my controllers using composer. However, my controllers are not namespaced.

Peter
  • 8,776
  • 6
  • 62
  • 95

1 Answers1

4

In cases when your project structure doesn't follow PSR-0 or PSR-4 standard, you can define a class map that could look like so:

{
    "autoload": {
        "classmap": ["application/controllers/"]
    }
}

It will scan the given directories and files for files with .php or .inc extensions and load them. You can read more about composer class maps here.

Kuba Birecki
  • 2,926
  • 1
  • 13
  • 16