php - Composer & Parsedown - Class 'UserFrostingParsedown' not found
Get the solution ↓↓↓I managed to install Parsedown using composer with
"require": {
...
"erusev/parsedown": "^1.6"
},
and added the class path to the autoload section
"autoload": {
"classmap" : [
"controllers", "middleware", "models", "plugins", "vendor/erusev/parsedown"
]
}
But when I try to execute this line...
$Parsedown = new Parsedown();
... I end up with this error:
Class 'UserFrosting\Parsedown' not found
Running php composer.phar dump-autoload did not help.
What am I missing here? Why Parsedown is expected under UserFrosting - UserFrosting\Parsedown?
Here is the full composer.json:
{
"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"
]
}
}
Answer
Solution:
Looks like you are trying to execute this line of code$Parsedown = new Parsedown();
in a class with namespaceUserFrosting
.
Either add ause
block at the top of your php file, like this:use Parsedown;
(this should come after namespace declaration), or type a backslash before the class name when you are using it, like so:$Parsedown = new \Parsedown();
. The latter will start looking for this class in a root namespace.
You don't need to add this class to your autoload classmap section ofcomposer.json
file. If a package is pulled by composer, the composer will automatically add everything to autoloader after running dump-autoload.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreign key constraint is incorrectly formed laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.