Home > database >  How can I use two classes with the same name?
How can I use two classes with the same name?

Time:01-30

I have installed two packages using Composer (PHP). One is

/Package1/Subfolder/Client

the second is named

/Package2/Subfolder2/Client

When I try to make instances of the two, PHP breaks with "PHP Fatal error: Cannot use package2\Subfolder2\Client as Client because the name is already in use".

Renaming didn't work. Too many files referring to the original.

CodePudding user response:

You can try to do:

use Package1\Subfolder2\Client as Client1;
use Package2\Subfolder2\Client as Client2;

Then you can use it as

new Client1;
new Client2;
  •  Tags:  
  • php
  • Related