composer-php - 未找到自己的包/类中的 Composer 自动加载
问题描述
我现在尝试了一些不同的方法并在这里和其他地方阅读文章,但我无法弄清楚我做错了什么。我正在开发一个包,我希望它通过符号链接安装在不同的项目中,以同时开发这两个部分,而无需一遍又一遍地更新依赖项。我无法工作的是自动加载。
这是我的设置:
项目作曲家.json
{
"repositories": [
{
"type": "path",
"url": "../../FormTableComponent",
"options": {
"symlink": true
}
}
],
"require": {
[...]
"bluechord/formtablecomponent": "@dev"
}
}
FormtableComponent 文件夹结构
FormTableComponent/
src/
| Container.php
composer.json
FormtableComponent composer.json
{
"name": "bluechord/formtablecomponent",
"description": "...",
"autoload": {
"psr-4": {
"BlueChord\\FormTableComponent\\": "src/"
}
},
"require" : {
[...]
}
}
FormtableComponent Container.php
<?php
/**
* FormTable Container. The Container Class that registers all Parts of the
* Component.
*/
namespace BlueChord\FormTableComponent;
class Container {
function __construct() {
}
}
当我尝试使用该类并实例化它时,我得到
Uncaught Error: Class 'BlueChord\FormTableComponent\Container' not found
谢谢你的帮助!
附加信息:
一个简单的 Test.php 重现项目内部的错误
<?php
require_once 'bin/vendor/autoload.php';
echo "BCOSP Test";
use DebugBar\StandardDebugBar;
use BlueChord\FormTableComponent\Container;
$debugbar = new StandardDebugBar(); --> WORKS
echo StandardDebugBar::class ."\n";
$container = new Container(); --> ERROR
echo Container::class . "\n";
作曲家
vendor/composer/autoload_psr4.php 不包含我的包的任何数组键。
如果我composer dump-autoload
在我的主项目中运行,则没有任何变化。如果我composer dump-autoload
在我的包中运行它会创建正确的 autoload_psr4.php
解决方案
推荐阅读
- java - 发布到 Maven 中心时缺少 jar 的签名 jar.asc
- c# - 单元测试未涵盖 LINQ `Any`
- javascript - 使用多个骰子时计算给定骰子掷骰的机会
- c# - 无法将“System.Single”类型的对象转换为“System.Double”类型。
- c++ - 哪些编译器支持在运行时固定大小的数组,哪些编译器不支持?
- python - 在 Pandas DataFrame 重新索引上丢失数据
- regex - 如何规范地解析模块名称
- azure-active-directory - Azure AD 如何将用户扩展属性传递给多租户应用程序
- dart - Dart 指定列表仅包含从另一个类扩展的对象
- bigcommerce - 我们如何将大商业与非常好的安全性 (VGS) 相结合