我设法安装了 parsedown 使用
的作曲家 "require": {
...
"erusev/parsedown": "^1.6"
},
并将类路径添加到自动加载部分
"autoload": {
"classmap" : [
"controllers", "middleware", "models", "plugins", "vendor/erusev/parsedown"
]
}
但是,当我尝试执行此行时...
$Parsedown = new Parsedown();
...我最终遇到了这个错误:
class'用户抛光 parsedown'找不到
运行 php composer.phar dump-autoload 没有帮助。
我在这里想念什么?为什么在用户抛光下预计会解放 - 用户冻结 parsedown?
这是完整的作曲家:
{
"name": "userfrosting/UserFrosting",
"type": "project",
"description": "A secure, modern user management system for PHP.",
"keywords": ["php user management", "usercake", "bootstrap"],
"homepage": "https://github.com/userfrosting/UserFrosting",
"license" : "MIT",
"authors" : [
{
"name": "Alexander Weissman",
"homepage": "https://alexanderweissman.com"
}
],
"require": {
"birke/rememberme" : "1.0.4",
"illuminate/database" : "5.0.33",
"league/csv": "8.1.*",
"nikic/php-parser" : "~1",
"php" : ">=5.4.0",
"phpmailer/phpmailer" : "5.2.10",
"twig/twig" : "~1.0",
"slim/slim" : "2.*",
"slim/views" : "0.1.3",
"userfrosting/fortress" : "1.*",
"wikimedia/composer-merge-plugin": "~1",
"components/highlightjs": "9.8.0",
"aws/aws-sdk-php": "3.*",
"erusev/parsedown": "^1.6"
},
"extra": {
"merge-plugin": {
"include": [
"plugins/*/composer.json"
],
"recurse": true,
"replace": false,
"merge-dev": true,
"merge-extra": false
}
},
"autoload": {
"classmap" : [
"controllers", "middleware", "models", "plugins", "vendor/erusev/parsedown"
]
}
}
看来您正在尝试在具有名称空间UserFrosting
的类中执行此类代码$Parsedown = new Parsedown();
。
在您的PHP文件的顶部添加一个use
块,例如:use Parsedown;
(这应该是在命名空间声明之后出现的),或者在使用该类名称时键入A BackSlash,例如So:$Parsedown = new Parsedown();
。后者将开始在根名称空间中寻找此类。
您不需要将此类添加到composer.json
文件的自动加载classmap部分中。如果作曲家将包裹拉动,则作曲家将在运行Dump-Autoload后自动将所有内容添加到自动加载器中。