简体   繁体   中英

ZF2 Tutorial error with TableGateway and AdapterInterface

I'm currently getting the following error:

Catchable fatal error: Argument 2 passed to Zend\Db\TableGateway\TableGateway::__construct() must implement interface Zend\Db\Adapter\AdapterInterface, none given, called in /vagrant/zend/module/Album/Module.php on line 33 and defined in /vagrant/zend/vendor/zendframework/zendframework/library/Zend/Db/TableGateway/TableGateway.php on line 31

I have been searching this for a while now and I'm only following the ZF2 tutorial. Any idea what can be wrong and how to solve it ?

After a few hours troubleshooting I have found out that the issue wasn't on the getServiceConfig method and it was one on the AlbumTable where I have forgot to add, on the construct, the TableGateway parameter.

The ZF2 error message doesn't help much and is misleading but once I have fixed the AlbumTable constructor (re-copied it) it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM