hedii's avatar

Hack to know if is lumen or if is laravel

Hi, very stupid question... Is there a way in a lumen app or laravel app, to know on which framework we currently are? Even a hack?

Something like:

if (is_lumen()) {
    do_somthing();
} elsif (is_laravel()) {
    do_other_thing();
}

where the is_lumen or is_laravel would be an artisan command or anything else that tells us on which framework we are?

0 likes
2 replies
bestmomo's avatar
Level 52

There is the artisan command :

php artisan --version
a7mad.sa3d's avatar

you can check the application instance namespace

Laravel \Illuminate\Foundation\Application Lumen \Laravel\Lumen\Application

So you can get the app instance and check

if (app() instanceof \Illuminate\Foundation\Application) {
    // Laravel
} else {
    // Lumen
}
2 likes

Please or to participate in this conversation.