简体   繁体   中英

Laravel package ServiceProvider not found

I have created a PHP package for laravel named zoho.

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()
        {

        }
    }

and composer file is

{
    "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"
        }
    ]
}

package is working fine when I created which is not in vendor folder but when I submitted to Packagist and install using composer and it shows the error

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

When running vendot:publish command even if provider rahulreghunath\\Zoho\\ServiceProvider::class, is added to config/app.php

is that any error in autoloading in composer file anyway thanks in advance

Found an answer myself

changed the composer.json to

{
    "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"
}

and service provider to

Rahulreghunath\Zoho\ServiceProvider::class,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM