Is there a way to import a single external PHP module that uses classes from other modules but same namespace?

I'm creating a tool that imports a php module from some other project and creates phpunit tests dynamically on the fly. I'm doing that by loading a module using include, and then performing some checks and creating my test cases. The problem I'm facing is with modules that use classes not defined directly in that module (but the same namespace for example).

I've tried using autoloading with composer, and passing in the classmap the classes I'm missing but this can be really tiresome and it doesn't always work (I had some issues with Laravel framework classes used in modules).

Anyways, I'm wondering what would be the best way to solve a problem like this?