Skip to content

Stash is unable to serialize() Closure in route #2

@webdevlabs

Description

@webdevlabs

I've noticed this issue when passing cached objects to anonymous functions for routing like
$router->get('/some', function () use ($someting) {});
the Stash caching library is unable to serialize() complicated Closure's in routes.
The problem is visible when we use ($something) and if $something is a cached object inside DI Container.
Normaly we don't need to do this. We can just pass a Controller class instead of objects inside anonymous functions. This is the correct usage: $router->get('/some', ['App\Class','myMethod']);

The solution is to avoid using Closures for Routes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions