PHP Composer PSR-4自动加载器不工作


PHP Composer PSR-4 autoloader not working

我正在尝试为我的一个旧库构建一个编写器包。我对GIT也有点陌生。这样做,我也在学习git工作流。我遵循这些文章来构建编译器包。

1 - http://culttt.com/2014/05/07/create-psr-4-php-package/

2 - https://knpuniversity.com/screencast/question-answer-day/create-composer-package

我已经上传了一个测试代码到Github知道一切工作正常。我的Github链接:https://github.com/mi6crazyheart/youtube-extract

但是,似乎当我通过Composer下载我的包时,它的自动加载器不起作用。在控制台文件中出现以下错误-

 Uncaught Error: Class 'Youtube''Extract' not found in /var/www/html/suresh/opensource/test/index.php:4'nStack trace:'n#0 {main}'n  thrown in /var/www/html/suresh/opensource/test/index.php on line 4

我的index.php文件的代码,我试图加载这个库

<?php
require __DIR__ . '/vendor/autoload.php';
$youtube = new Youtube'Extract();
echo $youtube->greeting();

我在composer.json文件中使用以下代码从git存储库下载代码

{
    "require": {
        "mi6crazyheart/youtube-extract": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mi6crazyheart/youtube-extract"
        }
    ]
}

我不知道我哪里做错了。需要一些指导。

您的命名空间是"Youtube'Extract",您的类是"Extract",这意味着您的代码使类Extract的新实例需要看起来像下面这样:

<?php
$youtube = new Youtube'Extract'Extract();