How to create Illuminate/Support/Facade/App facade for standalone Illuminate IoC Container

こ雲淡風輕ζ 提交于 2019-12-05 06:43:31
Patrick Stephan

You are missing one key component. The Application class needs to be bound to the container. The Facade is looking for a class to be bound to 'app' but nothing is, hence your error. You can fix the problem by binding the Illuminate\Container\Container class to 'app':

function setup_App(){
    $container = new Illuminate\Container\Container();
    Illuminate\Support\Facades\Facade::setFacadeApplication($container);
    $container->singleton('app', 'Illuminate\Container\Container');
    class_alias('Illuminate\Support\Facades\App', 'App');
}

setup_App();

App::bind('w', 'Widget');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!