Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
webdevlabs opened this issue Apr 2, 2017 · 2 comments
Open

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

webdevlabs opened this issue Apr 2, 2017 · 2 comments

Comments

@webdevlabs
Copy link
Owner

webdevlabs commented Apr 2, 2017

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.

@webdevlabs webdevlabs changed the title Stash is unable to serialize() Closure's in routes Stash is unable to serialize() Closure in route Apr 2, 2017
@webdevlabs
Copy link
Owner Author

this should be the perfect solution to be used globaly:
https://github.com/jeremeamia/super_closure

@webdevlabs
Copy link
Owner Author

webdevlabs commented Apr 5, 2017

This problem appears only when using the Stash Filesystem Driver, becouse it serializes data before saving it into files (thats good).
No problem when using Memcached/APC/Redis. Still not tested with the other drivers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant