Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

RPC end points not being created #77

Open
Danack opened this issue Oct 9, 2014 · 4 comments
Open

RPC end points not being created #77

Danack opened this issue Oct 9, 2014 · 4 comments

Comments

@Danack
Copy link

Danack commented Oct 9, 2014

Hi,

I'm trying to create an API with an RPC end point, and it doesn't seem to be happy.

I installed from https://github.com/zfcampus/zf-apigility-skeleton/releases/download/1.0.4/zf-apigility-skeleton-1.0.4.zip

I created an api called Guru - then clicked on "RPC services" => "Create New RPC Service". I set the service name to be "Accounts" and then added the end-point "/accounts" and clicked submit.

There was no error message, but the next screen said "No RPC services defined." and clicking around the interface there are no RPC endpoints listed.

Some files have been created; below is a screenshot of them as well as the contents of one of them:

apigilitynada

But the RPC endpoint is definitely not shown in the admin screens.

This is testing on OSX with:

> php -v
PHP 5.4.9 (cli) (built: Nov 23 2012 02:31:44) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

I have also have the same result when downloading the master from https://github.com/zfcampus/zf-apigility-skeleton

@Danack
Copy link
Author

Danack commented Oct 10, 2014

It looks like this is the Ajax call that is listing the RPC points:

http://127.0.0.1:8080/apigility/api/module/Guru/rpc?version=1

And it's definitely returning empty:

{"_links":{"self":{"href":"http://127.0.0.1:8080/apigility/api/module/Guru/rpc?version=1"}},"_embedded":{"rpc":[]},"total_items":0}

@Danack
Copy link
Author

Danack commented Oct 10, 2014

I think possibly the issue is due to some 'zf-rpc' and 'zf-rest' entries not being generated in the a config file somewhere.

Looking in the function ZF\Apigility\Admin\Model\ModuleModel::getServicesByModule

it's trying to figure out what RPC and Rest endpoints exist by trying to match the API name to the string at position 0 for each of the entries in that bit of config - so for me it's trying to match 'Guru' and failing to find it in the entries that it is searching:

array (size=19)
  0 => string 'ZF\Apigility\Admin\Controller\Authentication' (length=44)
  1 => string 'ZF\Apigility\Admin\Controller\Authorization' (length=43)
  2 => string 'ZF\Apigility\Admin\Controller\CacheEnabled' (length=42)
  3 => string 'ZF\Apigility\Admin\Controller\Config' (length=36)
  4 => string 'ZF\Apigility\Admin\Controller\Dashboard' (length=39)
  5 => string 'ZF\Apigility\Admin\Controller\Documentation' (length=43)
  6 => string 'ZF\Apigility\Admin\Controller\Filters' (length=37)
  7 => string 'ZF\Apigility\Admin\Controller\FsPermissions' (length=43)
  8 => string 'ZF\Apigility\Admin\Controller\HttpBasicAuthentication' (length=53)
  9 => string 'ZF\Apigility\Admin\Controller\HttpDigestAuthentication' (length=54)
  10 => string 'ZF\Apigility\Admin\Controller\Hydrators' (length=39)
  11 => string 'ZF\Apigility\Admin\Controller\InputFilter' (length=41)
  12 => string 'ZF\Apigility\Admin\Controller\ModuleConfig' (length=42)
  13 => string 'ZF\Apigility\Admin\Controller\ModuleCreation' (length=44)
  14 => string 'ZF\Apigility\Admin\Controller\OAuth2Authentication' (length=50)
  15 => string 'ZF\Apigility\Admin\Controller\SettingsDashboard' (length=47)
  16 => string 'ZF\Apigility\Admin\Controller\Source' (length=36)
  17 => string 'ZF\Apigility\Admin\Controller\Validators' (length=40)
  18 => string 'ZF\Apigility\Admin\Controller\Versioning' (length=40)

array (size=5)
  0 => string 'ZF\Apigility\Admin\Controller\ContentNegotiation' (length=48)
  1 => string 'ZF\Apigility\Admin\Controller\DbAdapter' (length=39)
  2 => string 'ZF\Apigility\Admin\Controller\Module' (length=36)
  3 => string 'ZF\Apigility\Admin\Controller\RpcService' (length=40)
  4 => string 'ZF\Apigility\Admin\Controller\RestService' (length=41)

My config file is above. Comparing it to the Apigility one at https://github.com/zfcampus/zf-apigility-example/blob/master/config/module.config.php it is clear that the example one does have entries for 'zf-rest' and 'zf-rpc', but the config file generated for me doesn't have them...

So it looks like they just haven't been generated correctly.

@Danack
Copy link
Author

Danack commented Oct 10, 2014

Actually the current generated config is different - it has many more entries, but still not the zf-rest or zf-rpc ones.

<?php
return array(
    'controllers' => array(
        'factories' => array(
            'Guru\\V1\\Rpc\\Test\\Controller' => 'Guru\\V1\\Rpc\\Test\\TestControllerFactory',
            'Guru\\V1\\Rpc\\Blah\\Controller' => 'Guru\\V1\\Rpc\\Blah\\BlahControllerFactory',
        ),
    ),
    'zf-content-negotiation' => array(
        'controllers' => array(
            'Guru\\V1\\Rpc\\Test\\Controller' => 'Json',
            'Guru\\V1\\Rpc\\Blah\\Controller' => 'Json',
        ),
        'accept_whitelist' => array(
            'Guru\\V1\\Rpc\\Test\\Controller' => array(
                0 => 'application/vnd.guru.v1+json',
                1 => 'application/json',
                2 => 'application/*+json',
            ),
            'Guru\\V1\\Rpc\\Blah\\Controller' => array(
                0 => 'application/vnd.guru.v1+json',
                1 => 'application/json',
                2 => 'application/*+json',
            ),
        ),
        'content_type_whitelist' => array(
            'Guru\\V1\\Rpc\\Test\\Controller' => array(
                0 => 'application/vnd.guru.v1+json',
                1 => 'application/json',
            ),
            'Guru\\V1\\Rpc\\Blah\\Controller' => array(
                0 => 'application/vnd.guru.v1+json',
                1 => 'application/json',
            ),
        ),
    ),
    'router' => array(
        'routes' => array(
            'guru.rest.test-reset' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/test-reset[/:test_reset_id]',
                    'defaults' => array(
                        'controller' => 'Guru\\V1\\Rest\\TestReset\\Controller',
                    ),
                ),
            ),
            'guru.rest.test2' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/test2[/:test2_id]',
                    'defaults' => array(
                        'controller' => 'Guru\\V1\\Rest\\Test2\\Controller',
                    ),
                ),
            ),
        ),
    ),
    'zf-versioning' => array(
        'uri' => array(
            0 => 'guru.rest.test-reset',
            1 => 'guru.rest.test2',
        ),
    ),
    'zf-hal' => array(
        'metadata_map' => array(
            'Guru\\V1\\Rest\\Test2\\Test2Entity' => array(
                'entity_identifier_name' => 'id',
                'route_name' => 'guru.rest.test2',
                'route_identifier_name' => 'test2_id',
                'hydrator' => 'Zend\\Stdlib\\Hydrator\\ArraySerializable',
            ),
            'Guru\\V1\\Rest\\Test2\\Test2Collection' => array(
                'entity_identifier_name' => 'id',
                'route_name' => 'guru.rest.test2',
                'route_identifier_name' => 'test2_id',
                'is_collection' => true,
            ),
        ),
    ),
);

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas-api-tools/api-tools-skeleton; a new issue has been opened at laminas-api-tools/api-tools-skeleton#19.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants