Skip to content

Conflict between two projects using the same package with file autoloading #130

@jakubmikita

Description

@jakubmikita

Let's assume we have a package with:

"autoload": {
	"files": [
		"src/functions.php"
	]
},

Where this functions.php file content is:

namespace PackageName

function my_func() {}

Now, when two different projects load the same package, they may have other prefixes:

  • ProjectOne\Vendor\
  • ProjectTwo\Vendor\

So in the first project which loads ealier you do:

ProjectOne\Vendor\PackageName\my_func();

which is fine, but the other:

ProjectTwo\Vendor\PackageName\my_func();

Gives function not found fatal error.

The reason why is because of both function.php files, despite changed namespace has the same content hash generated by composer autoloader. And because the file with given hash has been already loaded it doesn't load it again.

Any idea why this is happening? Does Imposter change the namespace after the Composer generates the file hashes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions