canfone
1 month ago
483
2
Lumen

Lumen 7 Class blade.compiler does not exist when building custom blade directives

Posted 1 month ago by canfone

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.

Please sign in or create an account to participate in this conversation.