Lumen 7 Class blade.compiler does not exist when building custom blade directives
I upgraded to Lumen 7.x and I can't figure out what did I miss. It returns Class blade.compiler does not exist . It seems some aliases are not properly loaded. Anyone here have encountered the same issue?
Here is my code.
bootstrap/app.php
$app = new Laravel\Lumen\Application(
dirname(__DIR__)
);
$app->withFacades();
$app->withEloquent();
$app->register(App\Providers\AppServiceProvider::class);
app/Providers/AppServiceProvider.php
/**
* Register any application services.
*
* @return void
*/
public function boot()
{
$timezone = 'UTC';
Blade::directive(
'date',
function ($expression) use ($timezone)
{
return "<?php echo ($expression)->timezone('$timezone')->format('Y-m-d'); ?>";
}
);
}
Every time I run php artisan command, it throws the error blade.compiler does not exists.
@artcore Thanks! I'll give it a try. Your solution might work and i'll stop using facades.
But I am just worried some facades like Blade are not working and I need to convert everything.