question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ziggy:generate doesn't worked with a cached routes file containing route closures - Function () does not exist error when running ziggy:generate

See original GitHub issue

Description

Running php artisan ziggy:generate works on my local machine.

In production I get the following error: Function () does not exist {"exception":"[object] (ReflectionException(code: 0): Function () does not exist at


Function () does not exist {"exception":"[object] (ReflectionException(code: 0): Function () does not exist at /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteSignatureParameters.php:23)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteSignatureParameters.php(23): ReflectionFunction->__construct()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(507): Illuminate\\Routing\\RouteSignatureParameters::fromAction()
#2 /var/www/html/vendor/tightenco/ziggy/src/Ziggy.php(152): Illuminate\\Routing\\Route->signatureParameters()
#3 /var/www/html/vendor/tightenco/ziggy/src/Ziggy.php(94): Tightenco\\Ziggy\\Ziggy->resolveBindings()
#4 /var/www/html/vendor/tightenco/ziggy/src/Ziggy.php(25): Tightenco\\Ziggy\\Ziggy->nameKeyedRoutes()
#5 /var/www/html/vendor/tightenco/ziggy/src/CommandRouteGenerator.php(37): Tightenco\\Ziggy\\Ziggy->__construct()
#6 /var/www/html/vendor/tightenco/ziggy/src/CommandRouteGenerator.php(27): Tightenco\\Ziggy\\CommandRouteGenerator->generate()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Tightenco\\Ziggy\\CommandRouteGenerator->handle()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\\Container\\BoundMethod::call()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call()
#13 /var/www/html/vendor/symfony/console/Command/Command.php(258): Illuminate\\Console\\Command->execute()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run()
#15 /var/www/html/vendor/symfony/console/Application.php(920): Illuminate\\Console\\Command->run()
#16 /var/www/html/vendor/symfony/console/Application.php(266): Symfony\\Component\\Console\\Application->doRunCommand()
#17 /var/www/html/vendor/symfony/console/Application.php(142): Symfony\\Component\\Console\\Application->doRun()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run()
#20 /var/www/html/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#21 {main}

Expected behavior

I’d expect the Ziggy routes file to be generated as in production.

Environment

  • Laravel version:  v8.14.0
  • Ziggy version:  v1.0.2 Related routes:

Ziggy call and context:

php artisan ziggy:generate

As far as I’m aware there are no big differences between the production and my local environment. Any insight into what’s causing this error and how to go about debugging further would be appreciated, but by no means expected 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
michaelklopfcommented, Jul 19, 2021

Hey, I would like to add another example of the problem which was solved by correctly calling an invokable controller.

Did not work

Route::patch('/user/clear', [ClearUserController::class])->name('user.clear');

Fixed it

Route::patch('/user/clear', ClearUserController::class)->name('user.clear');
0reactions
bakerkretzmarcommented, Jan 8, 2021

I’m pretty sure this isn’t an issue with Ziggy, but please feel free to comment here again or open a new issue if you’re able to reproduce it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel artisan route:cache causes Erroneous data Exception
It doesn't exist locally but is borked once it gets deployed on Vapor. I didn't have closures in my routes; and I get...
Read more >
Laravel: route:cache not use files in subdirectories
php when I wrote main routes and in this directory I created subdirectory routes/groups. There I have several files separate by some categories....
Read more >
"ip route show cached" doesn't work but man page says it does?
The main problem is that "man ip-route" keeps having multiple references to the cache table. * "cache - dump the routing cache." *...
Read more >
Laravel route caching for improved performance - VOLTAGE
If your routes are not cached, $this->loadRoutes() ends up calling the app/Providers/RouteServiceProvider.php map() function which maps Api routes ( ...
Read more >
workbox-routing - Chrome Developers
A service worker can intercept network requests for a page. It may respond to the browser with cached content, content from the network...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found