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.
解决 无用评论 打赏 举报