barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.23k stars 1.16k forks source link

:meta & spark.laravel.com? #343

Closed Nagle closed 4 years ago

Nagle commented 8 years ago

When I run

artisan ide-helper:meta

I get the following output:

PHP Fatal error:  Call to a member function make() on a non-object in …/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php on line 77

  [Symfony\Component\Debug\Exception\FatalErrorException]
  Call to a member function make() on a non-object

FormRequest.php:77

   use Illuminate\Contracts\Validation\Factory as ValidationFactory;
   # # #
   $factory = $this->container->make(ValidationFactory::class);

Since I am ignorant, I tried this w artisan tinker:

   app()->make(Illuminate\Contracts\Validation\Factory::class);

which gives

   => Illuminate\Validation\Factory {#216}

Then, I changed FormRequest.php:76-77 to

   dd($this);
   $factory = $this->container->make(ValidationFactory::class);

and ran artisan ide-helper:meta...

Laravel\Spark\Http\Requests\Auth\StripeRegisterRequest {#684
  #container: null
  #redirector: null
  #redirect: null
  #redirectRoute: null
  #redirectAction: null
  #errorBag: "default"
  #dontFlash: array:2 [
    0 => "password"
    1 => "password_confirmation"
  ]
  #json: null
  #convertedFiles: null
  #userResolver: null
  #routeResolver: null
  +attributes: Symfony\Component\HttpFoundation\ParameterBag {#687
    #parameters: []
  }
  +request: Symfony\Component\HttpFoundation\ParameterBag {#685
    #parameters: []
  }
  +query: Symfony\Component\HttpFoundation\ParameterBag {#686
    #parameters: []
  }
  +server: Symfony\Component\HttpFoundation\ServerBag {#690
    #parameters: []
  }
  +files: Symfony\Component\HttpFoundation\FileBag {#689
    #parameters: []
  }
  +cookies: Symfony\Component\HttpFoundation\ParameterBag {#688
    #parameters: []
  }
  +headers: Symfony\Component\HttpFoundation\HeaderBag {#691
    #headers: []
    #cacheControl: []
  }
  #content: null
  #languages: null
  #charsets: null
  #encodings: null
  #acceptableContentTypes: null
  #pathInfo: null
  #requestUri: null
  #baseUrl: null
  #basePath: null
  #method: null
  #format: null
  #session: null
  #locale: null
  #defaultLocale: "en"
}

Any suggestions on what to try next?

Cordially,

Henry

Chalkin commented 8 years ago

Having (almost) the same issue.

Put a var_dump on line 84 in /spark/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php

This i what I'm getting when doing: php artisan ide-helper:meta

/spark/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php:84:
string(4) "view"
/spark/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php:97:
/spark/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php:84:
string(35) "Laravel\Spark\Providers\ImageManger"
spark/vendor/barryvdh/laravel-ide-helper/src/Console/MetaCommand.php:97:

  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Fatal error: Call to a member function make() on null`
barryvdh commented 8 years ago

Sorry I don't have Spark. You could try to narrow down what instance gives problems, so I can ignore them in the configuration. Or if someone sponsors a licence for Spark, I'll see if I can reproduce ;)

zanematthew commented 8 years ago

Having the same issue as well.

Currently we can't share Spark licenses, due to the terms of service. However I don't see why @taylorotwell https://github.com/taylorotwell can't give you one for free so you can fix the issue.

garethlawson commented 8 years ago

Hi all,

I managed to get the command to run by temporarily commenting out this line that is within the 'providers' array in the config/app.php file: Illuminate\Foundation\Providers\FoundationServiceProvider::class

OR even better, to include the problematic instances in the meta command, I added a constructor to the vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php file as follows, to inject the container instance:

    public function __construct(array $query, array $request, array $attributes, array $cookies, array $files, array $server, $content, Container $container)
    {
        parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content);
        $this->container = $container;
    }

Add the above constructor method and then run the command and it shouldn't fail, at least not for the same reason. It seems that the $container property is supposed to be manually set using the setContainer() method when this class is used. Not sure why dependency injection was not used, but I'm sure there is a good reason.

Please note: These are just temporary workarounds. These changes should be reverted after successfully running the command as they will be overwritten when composer updates this file to a new version in any case, and will probably break something in the normal usage of the Spark application.

I also assume that this would only ever be done in a local/dev ENV, but just in case, I take no responsibility if doing the above breaks anything, and please don't do it in production! ;-)

@barryvdh - I'm not sure if this helps you in fixing the problem?

quiquegarcia commented 8 years ago

Hi everyone,

I think having a similar issue related to laravel/spark:

PHP Fatal error:  Call to a member function ownsTeam() on null in $pathToProject/spark/src/Http/Requests/Settings/Teams/Subscription/CreateSubscriptionRequest.php on line 22

Commenting out temporally SparkServiceProvider in config/app.php resolved the command as suggested by @garethlawson

Any idea on this issue?

atapatel commented 8 years ago

@quiquegarcia i am getting the same error.

lsmith77 commented 7 years ago

seems to be fixed in spark ..

mfn commented 4 years ago

This is the only issue talking specifically about problems with spark and the last comment indicates it's working

@barryvdh I neither use spark, but since the last feedback was 3 years ago and nothing else showed ever up, I vote for closing this issue :}