Creating new service providers in Silex

时光怂恿深爱的人放手 提交于 2019-12-06 12:58:58

First, you double-register the Company namespace, that may cause errors, may not - it's better to remove the redundancy anyway.

Second, it is not a good practice to edit anything under vendors, like you added a new class under Silex-Extensions. I usually put my app-related stuff in /app (bootstrap.php, config.php, appname.php) and classes, providers in /src. In this case you provider goes in /src/Company/Provider/FooProvider.php.

Third, all your provider does is register an autoload - you can do it in your bootstrap just fine, no reason to create a provider. It is needed if you create a service - meaning you go through the process of instantiating a class and assigning it to an index in $app (see pretty much any provider that comes with silex).

And last, you question mentions you try to use Postback in controllers.php, but that's not enough information. Did you add a use statement for it?

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