safe icon indicating copy to clipboard operation
safe copied to clipboard

Question: how can I use composers vendor/autoload.php from multiple projects using safe?

Open mfn opened this issue 2 years ago • 0 comments

Hi 👋🏼 ,

it might be related to https://github.com/thecodingmachine/safe/issues/53 or https://github.com/thecodingmachine/safe/issues/253

The problem:

  • I've two projects projectA/ and projectB/
  • completely separate projects, distinct namespacs, both using composer autoloading
  • both using thecodingmachine/safe:^2

I've a "glue" code which works a bit like:

require_once 'projectA/vendor/autoload.php';
require_once 'projectB/vendor/autoload.php';

// Do sommething with `ProjectA\Foo` and `ProjectB\Bar`

This used to work until both projects, which very well run and work on their own, got safe added and now it doesn't pass the second autoloader

PHP Fatal error: Cannot redeclare Safe\mysqli_get_client_stats() (previously declared in /projectA/vendor/thecodingmachine/safe/deprecated/mysqli.php:16) in /projectB/vendor/thecodingmachine/safe/generated/mysqli.php on line 34

Is there a way to get this working? I don't see anything like function_exists() in safe, so I guess not.

thx

mfn avatar Apr 17 '23 12:04 mfn