laravel-api-to-postman icon indicating copy to clipboard operation
laravel-api-to-postman copied to clipboard

ReflectionException

Open neopheus opened this issue 3 years ago • 1 comments

Hi,

on a project from scratch with Laravel 9.19

I have this error :


   ReflectionException

  Class "O:47:"Laravel\SerializableClosure\SerializableClosure":1:{s:12:"serializable";O:46:"Laravel\SerializableClosure\Serializers\Signed":2:{s:12:"serializable";s:295:"O:46:"Laravel\SerializableClosure\Serializers\Native":5:{s:3:"use";a:0:{}s:8:"function";s:77:"function (\Illuminate\Http\Request $request) {
    return $request->user();
}";s:5:"scope";s:37:"Illuminate\Routing\RouteFileRegistrar";s:4:"this";N;s:4:"self";s:32:"00000000000004400000000000000000";}";s:4:"hash";s:44:"/BJGjgLOCrK/HYxZhXaHlU4J/cO5KqbSFiXWK3axFYA=";}}" does not exist

  at vendor/andreaselia/laravel-api-to-postman/src/Commands/ExportPostmanCommand.php:205
    201▕             return new ReflectionFunction($routeAction['uses']);
    202▕         }
    203▕
    204▕         $routeData = explode('@', $routeAction['uses']);
  ➜ 205▕         $reflection = new ReflectionClass($routeData[0]);
    206▕
    207▕         if (! $reflection->hasMethod($routeData[1])) {
    208▕             return null;
    209▕         }

      +15 vendor frames
  16  artisan:37

composer.json

    "require": {
        "php": "^8.0.2",
        "andreaselia/laravel-api-to-postman": "^1.12",
        "google/apiclient": "^2.12.1",
        "guzzlehttp/guzzle": "^7.2",
        "laravel/framework": "^9.19",
        "laravel/sanctum": "^2.14.1",
        "laravel/tinker": "^2.7"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.15",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^6.1",
        "phpunit/phpunit": "^9.5.10",
        "spatie/laravel-ignition": "^1.0"
    },

and api.php (route)


Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

neopheus avatar Jul 09 '22 08:07 neopheus

Hi @neopheus,

Thank you for taking the time to create this issue.

Would you be able to provide some more information, as unfortunately, I have been unable to reproduce this issue locally.

As you can see from the screenshot below, I did the following:

# created a new laravel project
laravel new l9

# entered the brand new l9 directory
cd l9

# installed the package
composer require andreaselia/laravel-api-to-postman

# published the config
php artisan vendor:publish --provider="AndreasElia\PostmanGenerator\PostmanGeneratorServiceProvider" --tag="postman-config"

# ran the command
php artisan export:postman

CleanShot 2022-07-10 at 22 55 50@2x

Thanks, Andreas

andreaselia avatar Jul 10 '22 21:07 andreaselia

Closing this as no response yet received on reproduction of any possible issue.

andreaselia avatar Aug 06 '22 23:08 andreaselia

I'm thinking that this issue is because the action is an actual closure.

tomirons avatar Aug 09 '22 12:08 tomirons

I'm thinking that this issue is because the action is an actual closure.

I think I tested that by adding it to the local test suite with the other test routes, and it worked fine on my end 🤔

andreaselia avatar Aug 09 '22 13:08 andreaselia

I think I tested that by adding it to the local test suite with the other test routes, and it worked fine on my end 🤔

Interesting, I haven't tested this myself so you could be right. 😄

tomirons avatar Aug 09 '22 15:08 tomirons