scribe: Reflection Exception
- I confirm that I have read and attempted the tips in the Troubleshooting Guide.
Php artisan scribe:generate doesn’t work I’m getting this error

Screenshots and stack traces: With Verbose � info Processed route: [GET] _debugbar/open � info Processed route: [GET] _debugbar/clockwork/{id} � info Processed route: [GET] _debugbar/telescope/{id} � info Processed route: [GET] _debugbar/assets/stylesheets � info Processed route: [GET] _debugbar/assets/javascript � info Processed route: [DELETE] _debugbar/cache/{key}/{tags?}
ReflectionException
Class C:32:“Opis\Closure\SerializableClosure”:251:{ does not exist
at vendor/knuckleswtf/scribe/src/Commands/GenerateDocumentation.php:157 153▕ */ 154▕ private function doesControllerMethodExist(array $routeControllerAndMethod) 155▕ { 156▕ [$class, $method] = $routeControllerAndMethod; ➜ 157▕ $reflection = new ReflectionClass($class); 158▕ 159▕ if ($reflection->hasMethod($method)) { 160▕ return true; 161▕ }
1 vendor/knuckleswtf/scribe/src/Commands/GenerateDocumentation.php:157 ReflectionClass::__construct(“C:32:“Opis\Closure\SerializableClosure”:251:{”)
2 vendor/knuckleswtf/scribe/src/Commands/GenerateDocumentation.php:107 Knuckles\Scribe\Commands\GenerateDocumentation::doesControllerMethodExist()
3 vendor/knuckleswtf/scribe/src/Commands/GenerateDocumentation.php:73 Knuckles\Scribe\Commands\GenerateDocumentation::processRoutes()
4 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 Knuckles\Scribe\Commands\GenerateDocumentation::handle(Object(Knuckles\Scribe\Matching\RouteMatcher))
5 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 call_user_func_array()
6 vendor/laravel/framework/src/Illuminate/Container/Util.php:40 Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
7 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:95 Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
8 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:39 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
9 vendor/laravel/framework/src/Illuminate/Container/Container.php:596 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
10 vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Container\Container::call()
11 vendor/symfony/console/Command/Command.php:258 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
12 vendor/laravel/framework/src/Illuminate/Console/Command.php:121 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
13 vendor/symfony/console/Application.php:920 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
14 vendor/symfony/console/Application.php:266 Symfony\Component\Console\Application::doRunCommand(Object(Knuckles\Scribe\Commands\GenerateDocumentation), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
15 vendor/symfony/console/Application.php:142 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
16 vendor/laravel/framework/src/Illuminate/Console/Application.php:93 Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
17 vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129 Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
18 artisan:35 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
My environment:
- PHP version (from
php -v): 7.3.22 - Framework (Laravel/Lumen): Laravel
- Laravel/Lumen version (from
composer show laravel/frameworkorcomposer show lumen/framework): name : laravel/framework descrip. : The Laravel Framework. keywords : framework, laravel versions : * v8.10.0 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : https://laravel.com source : [git] https://github.com/laravel/framework.git 0c80950806cd1bc6d9a7068585a12c2bfa23bdf3 dist : [zip] https://api.github.com/repos/laravel/framework/zipball/0c80950806cd1bc6d9a7068585a12c2bfa23bdf3 0c80950806cd1bc6d9a7068585a12c2bfa23bdf3 path : /app/vendor/laravel/framework names : laravel/framework, psr/container-implementation, illuminate/auth, illuminate/broadcasting, illuminate/bus, illuminate/cache, illuminate/collections, illuminate/config, illuminate/console, illuminate/container, illuminate/ contracts, illuminate/cookie, illuminate/database, illuminate/encryption, illuminate/events, illuminate/filesystem, illuminate/hashing, illuminate/http, illuminate/log, illuminate/macroable, illuminate/mail, illuminate/notifications , illuminate/pagination, illuminate/pipeline, illuminate/queue, illuminate/redis, illuminate/routing, illuminate/session, illuminate/support, illuminate/testing, illuminate/translation, illuminate/validation, illuminate/view
autoload files psr-4 Illuminate\ => src/Illuminate/ Illuminate\Support\ => src/Illuminate/Macroable/, src/Illuminate/Collections/
requires doctrine/inflector ^1.4|^2.0 dragonmantank/cron-expression ^3.0 egulias/email-validator ^2.1.10 ext-json * ext-mbstring * ext-openssl * league/commonmark ^1.3 league/flysystem ^1.0.34 monolog/monolog ^2.0 nesbot/carbon ^2.17 opis/closure ^3.5.3 php ^7.3 psr/container ^1.0 psr/simple-cache ^1.0 ramsey/uuid ^4.0 swiftmailer/swiftmailer ^6.0 symfony/console ^5.1 symfony/error-handler ^5.1 symfony/finder ^5.1 symfony/http-foundation ^5.1 symfony/http-kernel ^5.1 symfony/mime ^5.1 symfony/process ^5.1 symfony/routing ^5.1 symfony/var-dumper ^5.1 tijsverkoyen/css-to-inline-styles ^2.2.2 vlucas/phpdotenv ^5.2 voku/portable-ascii ^1.4.8
requires (dev) aws/aws-sdk-php ^3.0 doctrine/dbal ^2.6 filp/whoops ^2.4 guzzlehttp/guzzle ^6.5.5|^7.0.1 league/flysystem-cached-adapter ^1.0 mockery/mockery ^1.3.1 orchestra/testbench-core ^6.0 pda/pheanstalk ^4.0 phpunit/phpunit ^8.4|^9.0 predis/predis ^1.1.1 symfony/cache ^5.1
- Scribe version (from
composer show knuckleswtf/scribe): 2.0.0-beta // had the same problem with 1.9
My Scribe config (minus the comments):
<?php return [ 'type' => 'static', 'static' => [ 'output_path' => 'public/docs', ], 'laravel' => [ 'add_routes' => true, 'docs_url' => '/docs', 'middleware' => [], ], 'auth' => [ 'enabled' => false, 'in' => 'bearer', 'name' => 'token', 'use_value' => env('SCRIBE_AUTH_KEY'), 'placeholder' => '{YOUR_AUTH_KEY}', 'extra_info' => 'You can retrieve your token by visiting your dashboard and clicking Generate API token.', ], 'intro_text' => <<<INTRO 'example_languages' => [ 'bash', 'javascript', ], 'base_url' => null, 'title' => null, 'description' => '', 'postman' => [ 'enabled' => true, 'overrides' => [ // 'info.version' => '2.0.0', ], ], 'openapi' => [ 'enabled' => true, 'overrides' => [ // 'info.version' => '2.0.0', ], ], 'default_group' => 'Endpoints', 'logo' => false, 'router' => 'laravel', 'routes' => [ [ 'match' => [ 'domains' => ['*'], 'prefixes' => ['*'], 'versions' => ['v1'], ], 'include' => [ // 'users.index', 'healthcheck*' ], 'exclude' => [ // '/health', 'admin.*' ], 'apply' => [ 'headers' => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'response_calls' => [ 'methods' => ['GET'], 'config' => [ 'app.env' => 'documentation', // 'app.debug' => false, ], 'cookies' => [ // 'name' => 'value' ], 'queryParams' => [ // 'key' => 'value', ], 'bodyParams' => [ // 'key' => 'value', ], 'fileParams' => [ // 'key' => '/home/me/image.png', ], ], ], ], ], 'fractal' => [ 'serializer' => null, ], 'faker_seed' => null, 'strategies' => [ 'metadata' => [ \Knuckles\Scribe\Extracting\Strategies\Metadata\GetFromDocBlocks::class, ], 'urlParameters' => [ \Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromUrlParamTag::class, ], 'queryParameters' => [ \Knuckles\Scribe\Extracting\Strategies\QueryParameters\GetFromQueryParamTag::class, ], 'headers' => [ \Knuckles\Scribe\Extracting\Strategies\Headers\GetFromRouteRules::class, \Knuckles\Scribe\Extracting\Strategies\Headers\GetFromHeaderTag::class, ], 'bodyParameters' => [ \Knuckles\Scribe\Extracting\Strategies\BodyParameters\GetFromFormRequest::class, \Knuckles\Scribe\Extracting\Strategies\BodyParameters\GetFromBodyParamTag::class, ], 'responses' => [ \Knuckles\Scribe\Extracting\Strategies\Responses\UseTransformerTags::class, \Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseTag::class, \Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseFileTag::class, \Knuckles\Scribe\Extracting\Strategies\Responses\UseApiResourceTags::class, \Knuckles\Scribe\Extracting\Strategies\Responses\ResponseCalls::class, ], 'responseFields' => [ \Knuckles\Scribe\Extracting\Strategies\ResponseFields\GetFromResponseFieldTag::class, ], ], 'routeMatcher' => \Knuckles\Scribe\Matching\RouteMatcher::class, 'continue_without_database_transactions' => [], ]; **Additional info:**About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (10 by maintainers)
I solved this problem by php artisan route:clear
This problem still persists. And it seems to be caused by opis/closure (required by Laravel 8.22.1)
I think this may actually be the solution. As far as I can tell, this isn’t a problem in Scribe.
Currently, my focus is on v3, so it will probably get fixed in v3, and then it may or may not be backported to v2.
Hmm. I’ll take another look at this. I think I have an idea of the cause. But I might not be able to get to it for a week or two.
Hmm, looks like it’s a problem with closure routes in Laravel (8?). (Should be a straightforward fix for this particular issue, but there may be issues in other places. 🤔) You’re using Closure routes, right?