beyondcode / invoker-community

74 stars 2 forks source link

Local project with Vapor core installed produces errors when "scan vendor folder" app is selected #300

Closed jkudish closed 1 year ago

jkudish commented 2 years ago

Heya,

I have some Models in my vendor folder that I wanted to include in Invoker so I turned on the scan vendors setting but it seems to have some kind of interference with the Vapor Core/Octane handler.

Let me know if you have a solution or if I can produce further information.

Cheers 🍻


OS: darwin Invoker Version: 2.9.0 Laravel Version: 9.18.0 Local project: true PHP Binary: /usr/local/bin/php Route: /home

Error:

Symfony\Component\ErrorHandler\Error\FatalError 

  Trait "Laravel\Octane\MarshalsPsr7RequestsAndResponses" not found

  at /Users/jkudish/dev/valet/turquoisegoat/vendor/laravel/vapor-core/src/Runtime/Handlers/OctaneHandler.php:11
      7β–• use Laravel\Vapor\Runtime\LambdaResponse;
      8β–• use Laravel\Vapor\Runtime\Octane\Octane;
      9β–• use Laravel\Vapor\Runtime\Octane\OctaneRequestContextFactory;
     10β–• 
  ➜  11β–• class OctaneHandler implements LambdaEventHandler
     12β–• {
     13β–•     use MarshalsPsr7RequestsAndResponses;
     14β–• 
     15β–•     /**

   Whoops\Exception\ErrorException 

  Trait "Laravel\Octane\MarshalsPsr7RequestsAndResponses" not found

  at /Users/jkudish/dev/valet/turquoisegoat/vendor/laravel/vapor-core/src/Runtime/Handlers/OctaneHandler.php:11
      7β–• use Laravel\Vapor\Runtime\LambdaResponse;
      8β–• use Laravel\Vapor\Runtime\Octane\Octane;
      9β–• use Laravel\Vapor\Runtime\Octane\OctaneRequestContextFactory;
     10β–• 
  ➜  11β–• class OctaneHandler implements LambdaEventHandler
     12β–• {
     13β–•     use MarshalsPsr7RequestsAndResponses;
     14β–• 
     15β–•     /**

      +1 vendor frames 
  2   [internal]:0
      Whoops\Run::handleShutdown()
jkudish commented 2 years ago

Seems like an issue you've encountered before #248

jkudish commented 2 years ago

Upon further investigation, this seems to happen because vapor-core includes some references to files found in laravel/octane which isn't installed in my project. Normally, this isn't an issue as the vapor-core package doesn't load the octane runtime unless explicitly set. However, as a result of Reflection, Invoker does try to find that namespace.

I don't know if Invoker has a blacklist of packages not to scan, but a possible solution would be ignore vapor-core when scanning the vendor folder. Rationale being that vapor-core doesn't (and is unlikely to ever) have any models in it.

mpociot commented 1 year ago

We added vapor-core to our internal ignore-list and will release this in an upcoming version.