PHP包含本地项目作为依赖项

I have two PHP projects A and B set up using composer. How do I include them as dependencies to project C.

I have tried it the following way, but I think it's not a recommended approach as path's are hardcoded

require_once 'pathtoA/autoload.php'
require_once 'pathtoB/autoload.php'

Within each project file there should be an individual namespace (PHP Manual ) declared to ensure names do not overlap.

file1:

<?php namespace foo;
  class Cat { 
    static function says() {echo 'meoow';}  } 
?>

file2:

<?php namespace bar;
  class Dog {
    static function says() {echo 'ruff';} } 
?>

To require the to files uses:

<?php
require('pathtoA/autoload.php');
require('pathtoB/autoload.php')'
?>