douzi8112 2015-12-09 22:00
浏览 42

是否在Laravel软件包中注册app.php中的服务提供商?

I've built a composer package for Laravel and it uses a Service Provider. I currently load it in the "providers" array in app.php after installing it to get it to work, but it seems like there should be a way to tell Composer to do that automatically to make set up easier for developers. Is that possible, or does it have to be done manually by the developer when they make a new package?

  • 写回答

1条回答 默认 最新

  • dongqing344716 2015-12-09 22:03
    关注

    Yes, it's required that you register the Service Provider in the app config. Even if you find a way to autoload your Service Provider with Composer, it doesn't know what a Service Provider is. You need to register it within the framework, because Laravel will handle calling your boot() and register() methods in the right order at the right time.

    评论

报告相同问题?