-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
config:cache command crashes on closures #9625
Comments
This has come up before. We don't support closures on purpose because the overhead of unserializing is greater than anything gained otherwise. |
Any config system that contain closures is badly designed. |
Any solution to this ? config:cache is unusable right now |
is it solved?? |
@GrahamCampbell I have to confess that my laravel and php skills are very rudimentary, so could you please advise me how I could solve the following task without closures? I want to dynamically declare CRUD routes if (!function_exists('registerResourceRoute')) {
function registerResourceRoute($endpoint, $tablename, $claim)
{
// Route::get($endpoint . '/{id}', $controller . '@getOne')->prefix('adminpanel')->middleware('jwtclaim:VIEW_' . strtoupper($endpoint));
//Get a list of records
//getList GET http://my.api.url/posts?sort=["title","ASC"]&range=[0, 24]&filter={"title":"bar"}
Route::get($endpoint, [
function (Request $request) use ($tablename, $endpoint) {
return App::make('App\Http\Controllers\CRUDController', ['tablename' => $tablename])->getList($request, $endpoint);
}
])->prefix('adminpanel')->middleware('jwtclaim:VIEW_' . $claim);
//Get a single record
// adminpanel/bookings/1
Route::get($endpoint . '/{id}', [
function (Request $request, string $id) use ($tablename) {
return App::make('App\Http\Controllers\CRUDController', ['tablename' => $tablename])->getOne($request, $id);
}
])->prefix('adminpanel')->middleware('jwtclaim:VIEW_' . $claim);
Route::post()
Route::delete()
.... registerResourceRoute('locations', 'public.location', 'DB');
registerResourceRoute('locationTranslations', 'public.locationTranslation', 'DB');
registerResourceRoute('locationMappings', 'public.location_mapping', 'DB');
registerResourceRoute('locationRegions', 'public.location_region', 'DB');
.... and 40 more The controller code is 100% identical between all controllers, how would the syntax look like to solve this task without the need to write 40 - 50 controllers and without closures? |
In laravel, when running the class TelegramBotHandler extends MonologTelegramBotHandler
{
public static function __set_state(array $array): TelegramBotHandler
{
return new self(
$array['apiKey'],
$array['channel'],
$array['level'],
$array['bubble'],
$array['parseMode'],
$array['disableWebPagePreview'],
$array['disableNotification'],
$array['splitLongMessages'],
$array['delayBetweenMessages'],
$array['topic']
);
}
} |
I have a third party package that uses a closure in its configuration (dingo/api), unfortunately that prevents me from using the
config:cache
command as this crashes the whole application with no friendly error message nor way to recover from it besides manually deleting the config cache:And the faulty part in the cached configuration file:
Shouldn't Laravel leverage serializable closures here?
The text was updated successfully, but these errors were encountered: