php - Laravel IoC outside Laravel -
i using repo basis new cli php project using eloquent orm.
when create new eloquent capsule
have option setasglobal
makes db capsule accessible anywhere in code.
does mean there's laravel container being used? or affecting db object?
i'd been using pimple container, if laravel has container can bind via eloquent, lot simpler-- want bind log writer, eloquent capsule, , settings object global container can access anywhere.
no not use laravels container. if @ method in trait: (github.com)
public function setasglobal() { static::$instance = $this; }
you can see sets static property on class containing current instance reused subsequent calls.
Comments
Post a Comment