Search code examples
phplaravelpackagepackagist

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": "[email protected]",
            "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


Solution

  • 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": "[email protected]",
                "role": "developer"
            }
        ],
        "require": {
            "php": ">=5.5.9"
        },
    
        "autoload": {
            "psr-4": {
                "Rahulreghunath\\Zoho\\": "src/"
            }
        },
        "minimum-stability": "dev"
    }
    

    and service provider to

    Rahulreghunath\Zoho\ServiceProvider::class,