How to use Apigility with an existing ZF2 applicat

2019-04-24 14:25发布

I have a ZF2 Application with some modules. I would like to allow use my existing modules with Apigility, inside my application.

I tried installing these modules with composer :

"require": {
    "php": ">=5.3.3",
    "phpoffice/phpexcel":"*",        
    "monolog/monolog" : "1.*",
    "zendframework/zend-developer-tools": "dev-master",
    "bjyoungblood/bjy-profiler": "dev-master",
    "radnan/rdn-router": "1.*",
    "bshaffer/oauth2-server-php": "dev-develop",
    "rwoverdijk/assetmanager": "~1.3",
    "zfcampus/zf-apigility": "~1.0-dev",
    "zfcampus/zf-apigility-provider": "~1.0-dev",
    "zfcampus/zf-apigility-documentation": "~1.0-dev",
    "zfcampus/zf-api-problem": "~1.0-dev",
    "zfcampus/zf-content-negotiation": "~1.0-dev",
    "zfcampus/zf-content-validation": "~1.0-dev",
    "zfcampus/zf-hal": "~1.0-dev",
    "zfcampus/zf-mvc-auth": "~1.0-dev",
    "zfcampus/zf-oauth2": "~1.0-dev",
    "zfcampus/zf-rest": "~1.0-dev",
    "zfcampus/zf-rpc": "~1.0-dev",
    "zfcampus/zf-versioning": "~1.0-dev"
},
"require-dev": {
    "zfcampus/zf-apigility-admin": "dev-master",
    "zfcampus/zf-configuration": "~1.0-dev",
    "zfcampus/zf-apigility-welcome": "~1.0-dev",
    "zendframework/zend-developer-tools": "dev-master"
}

I hade these modules in my application.config.php :

'ZF\\Apigility',
'ZF\\Apigility\\Provider',
'ZF\\Apigility\\Documentation',
'AssetManager',
'ZF\\ApiProblem',
'ZF\\MvcAuth',
'ZF\\OAuth2',
'ZF\\Hal',
'ZF\\ContentNegotiation',
'ZF\\ContentValidation',
'ZF\\Rest',
'ZF\\Rpc',
'ZF\\Versioning',

No Exception errors but can't go to Apigility config space. I already used Apigility from scratch with the zf-apigility-skeleton without problems. Route I tested local.project/apigility or local.project/apigility/documentation

I suppose I have a problem with routing or layout. I use the EPModuleLayouts to use differents layouts for each of my modules.

Thanks for you help

1条回答
贼婆χ
2楼-- · 2019-04-24 14:53

The Apigility config space you are referring to is the Apigility Admin which would be located at http://local.project/apigility/ui. Upon studying your configuration it appears you are missing two key modules; 'ZF\Apigility\Admin' and 'ZF\Configuration'. The ZF\Apigility\Admin module includes the AngularJS UI application for web service management, such as the code connected services you are trying to create. The ZF\Configuration module will allow Apigility to modify ZF2 configuration files.

Add 'ZF\Apigility\Admin' and 'ZF\Configuration' to your application.config.php module list and you should be able to access the admin.

WARNING: Do not load/include these modules in a production environment. You don't want random people messing around with your services.

You may want to look into the zfcampus/zf-development-mode module as it will allow you to easily manage loading modules within different environments such as development and production.

查看更多
登录 后发表回答