These are chat archives for composer/composer

1st
Dec 2015
Chuk Shirley
@chukShirley
Dec 01 2015 14:04
Anyone know if duplicate autoload entries cause problems? Here's what I'm trying to do in composer.json, but I haven't tested it yet:
{
  "autoload": {
    "classmap": ["Namespace1"],
    "psr-4":{
      "Namespace1":"src/Namespace1",
      "Namespace2":"src/Namespace2"
    }
}
Would Namespace1 have a conflict?
Chuk Shirley
@chukShirley
Dec 01 2015 15:25

This works...

{
  "autoload": {
    "classmap": ["Namespace1/"],
    "psr-4":{
      "Namespace1\\":"src/Namespace1",
      "Namespace2\\":"src/Namespace2"
    }
}

The "\\" and "/" differentiates between the two.

Rob
@alcohol
Dec 01 2015 16:40
you always need the trailing \\
it’s documented
Chuk Shirley
@chukShirley
Dec 01 2015 17:11
Even in classmap?
It's just psr-4, right?
Rob
@alcohol
Dec 01 2015 19:46
psr-4, psr-0
not classmap no, cause there is no namespace key there
its about the key, not the path
Chuk Shirley
@chukShirley
Dec 01 2015 19:47
Ahh... Makes sense. Thanks!
Rob
@alcohol
Dec 01 2015 19:47
it could lead to conflicts though
to answer your question
Chuk Shirley
@chukShirley
Dec 01 2015 19:48
How so?
Rob
@alcohol
Dec 01 2015 19:48
if there are similarly named classes inside Namespace1/ and src/Namespace1
that would lead to double definitions
and if you optimize the classmap, composer will warn you about it (run composer dump -o)
Chuk Shirley
@chukShirley
Dec 01 2015 19:49
Just tried it. No warnings. Does that mean there are no double definitions?
Rob
@alcohol
Dec 01 2015 19:50
correct
Chuk Shirley
@chukShirley
Dec 01 2015 19:50
All right! Thanks for the tip on dump -o. Haven't used that before.
Rob
@alcohol
Dec 01 2015 19:50
well dump is just short for dump-autoload
and -o is --optimize-classmap
err no, just --optimize
i forgot
Chuk Shirley
@chukShirley
Dec 01 2015 19:51
Okay. I had tried dump-autoload but wasn't sure if no warnings there meant no conflicts.
Rob
@alcohol
Dec 01 2015 19:51
now you can be sure :)
Chuk Shirley
@chukShirley
Dec 01 2015 19:52
:)