How do I register a service provider using Illuminate for non-laravel projects ?! How do I register a service provider using Illuminate for non-laravel projects ?!
Reply content:
How do I register a service provider using Illuminate for non-laravel projects ?!
Find the class registered by ServiceProvider and instantiate it directly.
You can refer to the implementation of laravel:
Illuminate \ Foundation \ Application
Class Example {public function say () {echo 'hello'; }}$ app = new Illuminate \ INER \ Container; $ app-> instance ('illuminate \ INER ', $ app); // shared container object // register a service $ app-> bind ('example ', function () {return new example ();}); $ app-> make ('example ')-> say (); // hello $ app2 = new Illuminate \ Container; // Obtain the shared Container object, that is, $ app $ app2-> make ('example ')-> say (); // hello