我是 Php 和 Composer 的新手,我想使用 Composer 将 Php 类访问到另一个模块,这是我的基本项目结构(两个模块 common 和 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
常见/供应商/画布/test.php
<?php
namespace test;
class test {
//put your code here
function __construct() {
echo "hello";
}
}
?>
普通/作曲家.json
{
"name":"canvass/test",
"type":"package",
"version": "1.0.0"
}
工人/作曲家.json
{
"autoload": {
"psr-4": {
"test":"../common/vendor/canvass"
}
}
}
工人/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();
?>
我也无法使用 psr-0 或存储库来做到这一点,有什么方法可以做到这一点吗?