How to start using Doctrine 2 in an Apigility appl

2019-06-21 19:13发布

问题:

I want to integrate the Doctrine 2 to an Apigility driven Zend Framework 2 application.

So I installed zfcampus/zf-apigility-doctrine

$ composer require zfcampus/zf-apigility-doctrine "~0.3"

and activated the modules Phpro\DoctrineHydrationModule, ZF\Apigility\Doctrine\Server, and ZF\Apigility\Doctrine\Admin in the application config files (/config/application.config.php and /config/development.config.php).

What should be done next to start using Doctrine in the application as general and particularly in the Apigility Admin area?

回答1:

I experimented with this Apigility extension in the fall but it was far from complete at that point. The server code was usable but there wasn't any UI integration to speak of. You can still manipulate endpoints by dissecting how zf-apigility-doctrine's controllers work and the information provided in the README. The rest is mostly trial and error. At the time I used the Postman plugin for Chrome to send requests to the endpoints mentioned in the README, trying different inputs until I found something that worked. It looks like they've made good progress on this portion of the integration since I last tried but I haven't revisited since to try again.

It seems there's no official integration with the Apigility admin UI yet. There is a repository for it (https://github.com/zfcampus/zf-apigility-admin-ui) but a quick browse of the open tickets shows it's not working yet. Someone has forked it and worked on it, but I haven't looked into it myself so I can't comment on it's readiness.

My suggestion is that if you want to learn how to integrate zf-apigility-doctrine into your Apigility the best way to do that right now is to take a look at Roll'n API (source here)