I am new to Php and composer, I want to access a Php class to another module using composer, This is my basic project structure (two modules common and worker) index.php
TestLocalRepository
--/Souce Files
--/common
--/vendor
--/canvass
--/test
--test.php
--/composer
--autoload.php
--composer.json
--/worker
--/vendor
--/composer
composer.json
temocaller.php
--index.php
common/vendor/canvass/test.php
<?php
namespace test;
class test {
//put your code here
function __construct() {
echo "hello";
}
}
?>
common/composer.json
{
"name":"canvass/test",
"type":"package",
"version": "1.0.0"
}
worker/composer.json
{
"autoload": {
"psr-4": {
"test":"../common/vendor/canvass"
}
}
}
worker/tempcaller.php
<?php
require_once dirname(__FILE__) . '../vendor/autoload.php';
use test;
class tempcaller {
//put your code here
function __construct() {
echo "tempcaller";
$obj = new test();
}
}
$t = new tempcaller();
?>
I am not able to do that with psr-0 or repositories either, is there any method to do this?