These are chat archives for composer/composer

4th
Nov 2017
FlyLo11
@FlyLo11
Nov 04 2017 15:08

hello,

{
  "autoload": {
    "psr-0": {
      "App_": "lib/App/"
    }
  }
}

this fails to load class App_Test_MyClass located in lib/App/Test/MyClass.php when doing composer dump-autoload
it works only with composer dump-autoload -o
am I missing something?

it works only when defining it as "":"lib/"
Owen Melbourne
@OwenMelbz
Nov 04 2017 15:55
tried psr4 autoloading instead?
dont think psr0 autoloadings been supported for several years now
FlyLo11
@FlyLo11
Nov 04 2017 15:56
yeah, i suppose so
Owen Melbourne
@OwenMelbz
Nov 04 2017 15:56
might find more docs/articles giving better help with that
FlyLo11
@FlyLo11
Nov 04 2017 15:57
from looking at the ClassLoader code, it replaces the underscore with a backslash, so App_ becomes App\, it assumes it's supposed to be a namespace
seems confusing, in docs it provides an example with underscores, i thought that means it expect partial class name, not a namespace
but it was still funny that dump-autoload -o just scans those directories and correctly builds the class map
Owen Melbourne
@OwenMelbz
Nov 04 2017 15:59
im not sure myself - have you tried using the classmap or files method?
"autoload": {
    "classmap": ["lib/App/"]
}
FlyLo11
@FlyLo11
Nov 04 2017 16:01
no, '":"lib/" solved it. i was curious if it was a bug or smth
i would probably expect a classmap would work too