I'm looking to encapsulate functionality that can be integrated into both a Laravel 5.6 webapp and a PHP-based command-line application. The functionality involves database interactivity.
For the sake of modularity, I decided to implement this functionality as a Composer module. Within the module, a constructor accepts an instance of Illuminate\Database\Capsule\Manager
. I believe this to be the appropriate way to use Eloquent outside of Laravel, and thus assumed it would serve as a satisfactory lowest common denominator among Laravel and the CLI-based application. (The module itself works great.)
I am now attempting to wrap this module within a Laravel Service Provider, and am encountering a problem: Laravel seems to mask its underlying Illuminate\Database\Capsule\Manager
resource behind a DB
"facade", which implements only static
methods.
Question: within Laravel, how can I access the underlying Illuminate\Database\Capsule\Manager
instance?
I'll note that I've been programming for 15+ years, but am relatively new to Laravel. With that said, if my thinking here is fundamentally contrary to the "Laravel way", please let me know of other architectural options. Thanks.