php - Zend framework 2- more than one RESTful api modules -


we have more 2 restful modules (restful & testservices). 1 rest module working @ time.

  1. if rearranged modules order in application.config.php , last module of rest api working .

    for example if keep 'testservices' module after " restful" module , "testservices" working. exmple - testservices : http://localhost/dev/public/testservices/userslist working fine .

if calling http://localhost/dev/public/restful/stateslist getting following error :

a 404 error occurred page not found. requested controller unable dispatch request. controller: application\controller\index

  1. if keep if keep ' restful ' module after " testservices " module , " restful " working. getting errors reverse of above.

here application.config.php

return array( // should array of module namespaces used in application. 'modules' => array(     'doctrinemodule',     'doctrineormmodule',     'application',     'ads',     'consumer',     'restful',     'cron',     'admin',     'payment',     'frontoffice',     'onboarding',     'testservices', ), // these various options listeners attached modulemanager 'module_listener_options' => array(     // should array of paths in modules reside.     // if string key provided, listener consider module     // namespace, value of key specific path module's     // module class.     'module_paths' => array(         './module',         './vendor',     ),     // array of paths glob configuration files after     // modules loaded. these overide configuration     // provided modules themselves. paths may use glob_brace notation.     'config_glob_paths' => array(         'config/autoload/{,*.}{global,local}.php',     ), // whether or not enable configuration cache. // if enabled, merged configuration cached , used in // subsequent requests. //'config_cache_enabled' => $booleanvalue, // key used create configuration cache file name. //'config_cache_key' => $stringkey, // whether or not enable module class map cache. // if enabled, creates module class map cache used // in future requests, reduce autoloading process. //'module_map_cache_enabled' => $booleanvalue, // key used create class map cache file name. //'module_map_cache_key' => $stringkey, // path in cache merged configuration. //'cache_dir' => $stringpath, // whether or not enable modules dependency checking. // enabled default, prevents usage of modules depend on other modules // weren't loaded. // 'check_dependencies' => true, ),     // used create own service manager. may contain 1 or more child arrays.     //'service_listener_options' => array(     //     array(     //         'service_manager' => $stringservicemanagername,     //         'config_key'      => $stringconfigkey,     //         'interface'       => $stringoptionalinterface,     //         'method'          => $stringrequiredmethodname,     //     ),     // )     // initial configuration seed servicemanager.     // should compatible zend\servicemanager\config.     // 'service_manager' => array(), 

);

here module.config.php restful module

  namespace restful;  return array( 'controllers' => array(     'invokables' => array(         'restful\controller\stateslist' => 'restful\controller\stateslistcontroller',         'restful\controller\citieslist' => 'restful\controller\citieslistcontroller',      ), ), 'router' => array(     'routes' => array(         'api' => array(             'type' => 'literal',             'options' => array(                 'route' => '/restful',                 'defaults' => array(                     '__namespace__' => 'restful\controller',                  ),             ),             'may_terminate' => true,             'child_routes' => array(                 'default' => array(                     'type' => 'segment',                     'options' => array(                         'route' => '/[:controller]',                         'constraints' => array(                             'controller' => '[a-za-z][a-za-z0-9_-]*'                         ),                         'defaults' => array(                         ),                     ),                 ),             ),         ),     ), ), 'view_manager' => array(     'template_path_stack' => array(         'api' => __dir__ . '/../view',     ),     'strategies' => array(         'viewjsonstrategy'     ) ), 

);

here module.config.php testservices module

  namespace testservices;   return array( 'controllers' => array(     'invokables' => array(         'testservices\controller\userslist' => 'testservices\controller\userslist',         'testservices\controller\roleslist' => 'testservices\controller\roleslistcontroller',      ), ), 'router' => array(     'routes' => array(         'api' => array(             'type' => 'literal',             'options' => array(                 'route' => '/testservices',                 'defaults' => array(                     '__namespace__' => 'testservices\controller',                  ),             ),             'may_terminate' => true,             'child_routes' => array(                 'default' => array(                     'type' => 'segment',                     'options' => array(                         'route' => '/[:controller]',                         'constraints' => array(                             'controller' => '[a-za-z][a-za-z0-9_-]*'                         ),                         'defaults' => array(                         ),                     ),                 ),             ),         ),     ), ), 'view_manager' => array(     'template_path_stack' => array(         'api' => __dir__ . '/../view',     ),     'strategies' => array(         'viewjsonstrategy'     ) ), 

);

thanks in advance.

both routes use key api in module.config.php assume when gets merged last 1 loaded wins. change 1 of them like:

'router' => array(     'routes' => array(         'api_changed' => array(             'type' => 'literal',             'options' => array(                 'route' => '/testservices',                 'defaults' => array(                     '__namespace__' => 'testservices\controller',                  ),             ),             'may_terminate' => true,             'child_routes' => array(                 'default' => array(                     'type' => 'segment',                     'options' => array(                         'route' => '/[:controller]',                         'constraints' => array(                             'controller' => '[a-za-z][a-za-z0-9_-]*'                         ),                         'defaults' => array(                         ),                     ),                 ),             ),         ),     ), ), 

where api has been updated api_changed


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -