lumen - Class 'Log' not found -
i'm new lumen , laravel, have write rest api using lumen. i've set controller , i'm having problem using logger. i've followed documentation: lumen docs
this controller app/http/controllers/documentscontroller.php:
namespace app\http\controllers; use illuminate\http\request; use log; class documentscontroller extends controller { public function index() { log::info('test'); return response()->json(['result' => 'oh hey!']); } }
if run i'm getting error saying:
fatalerrorexception in documentscontroller.php line 22: class 'log' not found
so there seems wrong log facade (not quite sure how work yet in laravel/lumen).
but if change log::info() call, manually pull log service out of di container works:
$app = app(); $app->make('log')->info('test');
any ideas why facade method described in official documentation isn't working?
doh , of course 5 minutes after posting question figured out. noticed in application base class (vendor/laravel/lumen-framework/src/application.php) following aliases:
public function withfacades() { facade::setfacadeapplication($this); if (! static::$aliasesregistered) { static::$aliasesregistered = true; class_alias('illuminate\support\facades\auth', 'auth'); class_alias('illuminate\support\facades\cache', 'cache'); class_alias('illuminate\support\facades\db', 'db'); class_alias('illuminate\support\facades\event', 'event'); class_alias('illuminate\support\facades\gate', 'gate'); class_alias('illuminate\support\facades\log', 'log'); class_alias('illuminate\support\facades\queue', 'queue'); class_alias('illuminate\support\facades\schema', 'schema'); class_alias('illuminate\support\facades\url', 'url'); class_alias('illuminate\support\facades\validator', 'validator'); } }
this method never called however, because in bootstrap/app.php $this->withfacades() call commented out default.
i uncommented , works.
Comments
Post a Comment