'Michelf\Markdown' class 未找到
'Michelf\Markdown' class not found
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$my_text = " a";
use \Michelf\Markdown;
$my_html = Markdown::defaultTransform($my_text);
echo "end";
不幸的是,它不起作用。我收到错误:
Fatal error: Uncaught Error: Class 'Michelf\Markdown' not found in /path/to/index.php:8 Stack trace: #0 {main} thrown in /path/to/index.php on line 8
我搜索了一下,发现有人had a similar issue。但是添加 'Michelf\' 并没有改变任何东西:
$my_html = \Michelf\Markdown::defaultTransform($my_text);
我收到了同样的错误信息。
这是我的文件树:
/path/to/
|- index.php
`- Michelf/
|- Markdown.php
|- MarkdownInterface.php
`- […]
如果您以正确的方式使用,该软件包假设您使用了自动加载器。我的意思是composer。我可能是错的,但是,如果你使用的是 composer,库的路径应该位于 /vendor
目录
下
require_once 'vendor/autoload.php';
use Michelf\Markdown;
$my_text = 'a';
$my_html = Markdown::defaultTransform($my_text);
或者,如果您没有使用 composer,库的自述文件会告诉您如何使用它 here
require_once 'Michelf/Markdown.inc.php';
use Michelf\Markdown;
$my_text = 'a';
$my_html = Markdown::defaultTransform($my_text);
对我有用的是:
composer require michelf/php-markdown
composer dump-autoload
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$my_text = " a";
use \Michelf\Markdown;
$my_html = Markdown::defaultTransform($my_text);
echo "end";
不幸的是,它不起作用。我收到错误:
Fatal error: Uncaught Error: Class 'Michelf\Markdown' not found in /path/to/index.php:8 Stack trace: #0 {main} thrown in /path/to/index.php on line 8
我搜索了一下,发现有人had a similar issue。但是添加 'Michelf\' 并没有改变任何东西:
$my_html = \Michelf\Markdown::defaultTransform($my_text);
我收到了同样的错误信息。
这是我的文件树:
/path/to/
|- index.php
`- Michelf/
|- Markdown.php
|- MarkdownInterface.php
`- […]
如果您以正确的方式使用,该软件包假设您使用了自动加载器。我的意思是composer。我可能是错的,但是,如果你使用的是 composer,库的路径应该位于 /vendor
目录
require_once 'vendor/autoload.php';
use Michelf\Markdown;
$my_text = 'a';
$my_html = Markdown::defaultTransform($my_text);
或者,如果您没有使用 composer,库的自述文件会告诉您如何使用它 here
require_once 'Michelf/Markdown.inc.php';
use Michelf\Markdown;
$my_text = 'a';
$my_html = Markdown::defaultTransform($my_text);
对我有用的是:
composer require michelf/php-markdown
composer dump-autoload