Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC end points not being created #19

Open
weierophinney opened this issue Dec 31, 2019 · 3 comments
Open

RPC end points not being created #19

weierophinney opened this issue Dec 31, 2019 · 3 comments

Comments

@weierophinney
Copy link
Contributor

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


Originally posted by @Danack at zfcampus/zf-apigility-skeleton#77

@weierophinney
Copy link
Contributor Author

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}


Originally posted by @Danack at zfcampus/zf-apigility-skeleton#77 (comment)

@weierophinney
Copy link
Contributor Author

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.


Originally posted by @Danack at zfcampus/zf-apigility-skeleton#77 (comment)

@weierophinney
Copy link
Contributor Author

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,
            ),
        ),
    ),
);

Originally posted by @Danack at zfcampus/zf-apigility-skeleton#77 (comment)

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

No branches or pull requests

1 participant