Laravel 找不到包服务提供者

Laravel package ServiceProvider not found

我为 laravel 创建了一个名为 zoho 的 PHP 包。

namespace rahulreghunath\zoho;
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;

    class ServiceProvider extends IlluminateServiceProvider
    {
        /**
         * Bootstrap the application services.
         *
         * @return void
         */
        public function boot()
        {
            $this->publishes([
                __DIR__.'/../config/zoho.php' => config_path('zoho.php'),
            ]);

        }

        /**
         * Register the application services.
         *
         * @return void
         */
        public function register()
        {

        }
    }

作曲家文件是

{
    "name": "rahulreghunath/zoho",
    "minimum-stability": "dev",
    "require": {
    },
    "description": "PHP form validation plugin ",
    "homepage": "https://github.com/rahulreghunath/zoho-crm",
    "license": "MIT",
    "authors": [
        {
            "name": "Rahul Reghunath",
            "email": "reghunath11@gmail.com",
            "role": "developer"
        }
    ]
}

当我创建的包不在 vendor 文件夹中但当我创建时包工作正常 提交给 Packagist 并使用 composer 安装,它显示错误

[Symfony\Component\Debug\Exception\FatalErrorException]  
  Class 'rahulreghunath\zoho\ServiceProvider' not found

当运行vendot:publish命令时 即使提供者 rahulreghunath\Zoho\ServiceProvider::class, 添加到 config/app.php

是composer文件自动加载有什么错误 无论如何提前谢谢

自己找到答案

将 composer.json 更改为

{
    "name": "rahulreghunath/zoho",
    "description": "Zoho CRM integration for PHP-Laravel",
    "license": "MIT",
    "keywords": ["laravel", "zoho"],
    "authors": [
        {
            "name": "Rahul Reghunath",
            "email": "reghunath11@gmail.com",
            "role": "developer"
        }
    ],
    "require": {
        "php": ">=5.5.9"
    },

    "autoload": {
        "psr-4": {
            "Rahulreghunath\Zoho\": "src/"
        }
    },
    "minimum-stability": "dev"
}

和服务提供商

Rahulreghunath\Zoho\ServiceProvider::class,