How do I create adapter for connect database Zend Framework 2?

I try to follow this and create adapter to connect database. But I got an error:

Deprecated: You are retrieving the service locator from within the class Account\Controller\AController. Please be aware that ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. You will need to update your class to accept all dependencies at creation, either via constructor arguments or setters, and use a factory to perform the injections. in D:\Programs\xampp\htdocs\wmsv2\vendor\zendframework\zend-mvc\src\Controller\AbstractController.php on line 258

I did many ways and long time to seach but not success. How do I connect to database? I’m using ZF 2.5.1.

Hey @namnguyen2091,

I don’t use Zend Framework anymore (not since v1, in fact) but a quick Google search turned up this explanation from one of the maintainers which includes some code examples showing you how to resolve the issue.

I tried to use ZF2 in serval day but I see it’s too complex, they’ll remove ServiceLocatorAwareInterface class in ZF 3 but why this still in a long time in ZF2. I can not connect to database, try many ways and do follow ZF2 doc but I can’t. I feel very disapointed so I moved from ZF2 to Lavarel 5. In the first time I can connect DB, create modules, templates very easy.
Thank for your help! Many thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.