未找到Composer类错误

时间:2017-12-13 15:36:03

标签: php composer-php package

我一直在做一个项目,我需要制作一个包。但它总是返回

PHP Fatal error:  Uncaught Error: Class 'youtubetomp3\downloader' not found

这里是目录的结构。

youtubetomp3/
  src/
    downloader.php
  test/
    downloaderTest.php
  composer.json
  composer.lock
  and other files

composer.json包含以下详细信息。

{
    "name": "princeyadav05/youtubetomp3",
    "description": "Downloads mp3 of a video given video-id",
    "keywords": ["youtube", "songs", "downloader", "package"],
    "license": "",
    "authors": [
        {
            "name": "Prince Yadav",
            "email": "princeyadav96@gmail.com"
        }
    ],
    "type": "package",
    "require": {
        "php": ">=5.4",
        "php-ffmpeg/php-ffmpeg": "^0.11.0"
    },
    "require-dev": {
        "phpunit/phpunit": "5.2.*"
    },
    "autoload": {
        "psr-4": {
            "princeyadav05\\youtubetomp3\\": "src/"
        }
    }
}

这就是我创建课堂对象的方式。

<?php
require 'vendor/autoload.php';
require 'scrapper.php';
include 'database.php';

echo "** WELCOME TO THE MP3 DOWNLOADER ** \n \n";
$name = readline("Hey There. Lets start with your name : ");
echo "\nHello " . $name . ".\n";


$search = readline("Please enter the search query : ");
$data_array = searchVideo($search); //returns data array
displayVideos($data_array); // returns video id
$download = new downloader();
$video_details = $download->downloadSong($video_id);
// returns array with video title, Duration, url, path
savingToDb($video_title, $video_duration, $video_url, $songs_path);
?>

请帮忙。我尝试了很多东西,但没有任何效果。我真的很沮丧。

1 个答案:

答案 0 :(得分:0)

目前尚不清楚你是否包含了作曲家生成的autoload.php文件。你介意发布完整的代码吗?

然后我不确定你的自动加载指令,我会尝试这样的事情:

"autoload": {
    "classmap": [
        "src/"
    ]
},

请参阅作曲家文档了解更多信息