FatalErrorException In ProviderRepository.php Line 146: Cannot Instantiate Abstract Class App\Modules\ModuleServiceProvider

- 1 answer

I have used laravel 5.2 for my project. For a modular approach I have modules in app > modules, and in modules > user.

module > ModuleServiceProvider.php is as below:

<?php namespace App\Modules;

use \Illuminate\Support\ServiceProvider as ServiceProvider;
abstract class ModuleServiceProvider extends  ServiceProvider{

  public function boot() {
    if ($module = $this->getModule(func_get_args())) {
      $this->package("app/" . $module, $module, app_path() . "/modules/" . $module);

  public function register() {

    if ($module = $this->getModule(func_get_args())) {
      $this->app["config"]->package("app/" . $module, app_path() . "/modules/" . $module . "/config");

        // Add routes
      $routes = app_path() . "/modules/" . $module . "/routes.php";
      if (file_exists($routes))
        require $routes;

  public function getModule($args) {
    $module = (isset($args[0]) and is_string($args[0])) ? $args[0] : null;
    return $module;



and my LeadServiceProvider.php is like

<?php  namespace App\Modules\Lead;

 class LeadServiceProvider extends \App\Modules\ModuleServiceProvider {

public function register()

public function boot()
 * Register any application services.
 * @return void


i have written it in my app.php providers too


App\Modules\ModuleServiceProvider::class, App\Modules\Lead\LeadServiceProvider::class,

Also written in composer.json too.

but it gives error like

FatalErrorException in ProviderRepository.php line 146: Cannot instantiate abstract class App\Modules\ModuleServiceProvider



You cannot instantiate an abstract class. An abstract class MUST be extended by another class. However, it appears that your ModuleServiceProvider does not contain any abstract methods, so it shouldn't need to be abstract. Drop the abstract keyword from your service provider and that should fix the problem.