czeeb / apigility-doctrine-example

An example repository for the changes necessary to get doctrine working with apigility
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Unable to create doctrine connected rest service #1

Open czeeb opened 9 years ago

czeeb commented 9 years ago

As of d36c405a22abf0deafd9f81285f1f1f8c0bb3bbe I am unable to create a doctrine connected rest service.

Up until this point all I have done in the UI is create the DoctrineExample API. I have not created any services.

When attempting to create a new service via the API from zfcampus/zf-apigility-doctrine I get the following output:

$ curl --silent -XPOST -H 'Content-Type: application/json'  localhost:8888/apigility/api/module/DoctrineExample/doctrine --data '{"objectManager":"doctrine.entitymanager.orm_default","serviceName":"Planet","entityClass":"Db\\Entity\\Planet","routeIdentifierName":"planet_id", "entityIdentifierName":"id", "routeMatch":"/api/planet"}' | python -m json.tool
{
    "detail": "Unable to create REST service",
    "exception_stack": [
        {
            "code": 422,
            "message": "Invalid object manager specified. Must be declared in the service manager.",
            "trace": [
                {
                    "args": [
                        {}
                    ],
                    "class": "ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceModel",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-apigility-doctrine/src/Admin/Model/DoctrineRestServiceResource.php",
                    "function": "createService",
                    "line": 120,
                    "type": "->"
                },
                {
                    "args": [
                        {
                            "entityClass": "Db\\Entity\\Planet",
                            "entityIdentifierName": "id",
                            "objectManager": "doctrine.entitymanager.orm_default",
                            "routeIdentifierName": "planet_id",
                            "routeMatch": "/api/planet",
                            "serviceName": "Planet"
                        }
                    ],
                    "class": "ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceResource",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/AbstractResourceListener.php",
                    "function": "create",
                    "line": 157,
                    "type": "->"
                },
                {
                    "args": [
                        {}
                    ],
                    "class": "ZF\\Rest\\AbstractResourceListener",
                    "function": "dispatch",
                    "type": "->"
                },
                {
                    "args": [
                        [
                            {},
                            "dispatch"
                        ],
                        {}
                    ],
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
                    "function": "call_user_func",
                    "line": 444
                },
                {
                    "args": [
                        "create",
                        {},
                        {}
                    ],
                    "class": "Zend\\EventManager\\EventManager",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
                    "function": "triggerListeners",
                    "line": 205,
                    "type": "->"
                },
                {
                    "args": [
                        {},
                        {}
                    ],
                    "class": "Zend\\EventManager\\EventManager",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/Resource.php",
                    "function": "trigger",
                    "line": 246,
                    "type": "->"
                },
                {
                    "args": [
                        {
                            "entityClass": "Db\\Entity\\Planet",
                            "entityIdentifierName": "id",
                            "objectManager": "doctrine.entitymanager.orm_default",
                            "routeIdentifierName": "planet_id",
                            "routeMatch": "/api/planet",
                            "serviceName": "Planet"
                        }
                    ],
                    "class": "ZF\\Rest\\Resource",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/RestController.php",
                    "function": "create",
                    "line": 369,
                    "type": "->"
                },
                {
                    "args": [
                        {
                            "entityClass": "Db\\Entity\\Planet",
                            "entityIdentifierName": "id",
                            "objectManager": "doctrine.entitymanager.orm_default",
                            "routeIdentifierName": "planet_id",
                            "routeMatch": "/api/planet",
                            "serviceName": "Planet"
                        }
                    ],
                    "class": "ZF\\Rest\\RestController",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/RestController.php",
                    "function": "create",
                    "line": 906,
                    "type": "->"
                },
                {
                    "args": [
                        {}
                    ],
                    "class": "ZF\\Rest\\RestController",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php",
                    "function": "processPostData",
                    "line": 416,
                    "type": "->"
                },
                {
                    "args": [
                        {}
                    ],
                    "class": "Zend\\Mvc\\Controller\\AbstractRestfulController",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/RestController.php",
                    "function": "onDispatch",
                    "line": 332,
                    "type": "->"
                },
                {
                    "args": [
                        {}
                    ],
                    "class": "ZF\\Rest\\RestController",
                    "function": "onDispatch",
                    "type": "->"
                },
                {
                    "args": [
                        [
                            {},
                            "onDispatch"
                        ],
                        {}
                    ],
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
                    "function": "call_user_func",
                    "line": 444
                },
                {
                    "args": [
                        "dispatch",
                        {},
                        {}
                    ],
                    "class": "Zend\\EventManager\\EventManager",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
                    "function": "triggerListeners",
                    "line": 205,
                    "type": "->"
                },
                {
                    "args": [
                        "dispatch",
                        {},
                        {}
                    ],
                    "class": "Zend\\EventManager\\EventManager",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php",
                    "function": "trigger",
                    "line": 118,
                    "type": "->"
                },
                {
                    "args": [
                        {},
                        {}
                    ],
                    "class": "Zend\\Mvc\\Controller\\AbstractController",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php",
                    "function": "dispatch",
                    "line": 300,
                    "type": "->"
                },
                {
                    "args": [
                        {},
                        {}
                    ],
                    "class": "Zend\\Mvc\\Controller\\AbstractRestfulController",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/DispatchListener.php",
                    "function": "dispatch",
                    "line": 93,
                    "type": "->"
                },
                {
                    "args": [
                        {}
                    ],
                    "class": "Zend\\Mvc\\DispatchListener",
                    "function": "onDispatch",
                    "type": "->"
                },
                {
                    "args": [
                        [
                            {},
                            "onDispatch"
                        ],
                        {}
                    ],
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
                    "function": "call_user_func",
                    "line": 444
                },
                {
                    "args": [
                        "dispatch",
                        {},
                        {}
                    ],
                    "class": "Zend\\EventManager\\EventManager",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
                    "function": "triggerListeners",
                    "line": 205,
                    "type": "->"
                },
                {
                    "args": [
                        "dispatch",
                        {},
                        {}
                    ],
                    "class": "Zend\\EventManager\\EventManager",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Application.php",
                    "function": "trigger",
                    "line": 314,
                    "type": "->"
                },
                {
                    "args": [],
                    "class": "Zend\\Mvc\\Application",
                    "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/public/index.php",
                    "function": "run",
                    "line": 51,
                    "type": "->"
                }
            ]
        }
    ],
    "status": 422,
    "title": "Unprocessable Entity",
    "trace": [
        {
            "args": [
                {
                    "entityClass": "Db\\Entity\\Planet",
                    "entityIdentifierName": "id",
                    "objectManager": "doctrine.entitymanager.orm_default",
                    "routeIdentifierName": "planet_id",
                    "routeMatch": "/api/planet",
                    "serviceName": "Planet"
                }
            ],
            "class": "ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceResource",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/AbstractResourceListener.php",
            "function": "create",
            "line": 157,
            "type": "->"
        },
        {
            "args": [
                {}
            ],
            "class": "ZF\\Rest\\AbstractResourceListener",
            "function": "dispatch",
            "type": "->"
        },
        {
            "args": [
                [
                    {},
                    "dispatch"
                ],
                {}
            ],
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
            "function": "call_user_func",
            "line": 444
        },
        {
            "args": [
                "create",
                {},
                {}
            ],
            "class": "Zend\\EventManager\\EventManager",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
            "function": "triggerListeners",
            "line": 205,
            "type": "->"
        },
        {
            "args": [
                {},
                {}
            ],
            "class": "Zend\\EventManager\\EventManager",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/Resource.php",
            "function": "trigger",
            "line": 246,
            "type": "->"
        },
        {
            "args": [
                {
                    "entityClass": "Db\\Entity\\Planet",
                    "entityIdentifierName": "id",
                    "objectManager": "doctrine.entitymanager.orm_default",
                    "routeIdentifierName": "planet_id",
                    "routeMatch": "/api/planet",
                    "serviceName": "Planet"
                }
            ],
            "class": "ZF\\Rest\\Resource",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/RestController.php",
            "function": "create",
            "line": 369,
            "type": "->"
        },
        {
            "args": [
                {
                    "entityClass": "Db\\Entity\\Planet",
                    "entityIdentifierName": "id",
                    "objectManager": "doctrine.entitymanager.orm_default",
                    "routeIdentifierName": "planet_id",
                    "routeMatch": "/api/planet",
                    "serviceName": "Planet"
                }
            ],
            "class": "ZF\\Rest\\RestController",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/RestController.php",
            "function": "create",
            "line": 906,
            "type": "->"
        },
        {
            "args": [
                {}
            ],
            "class": "ZF\\Rest\\RestController",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php",
            "function": "processPostData",
            "line": 416,
            "type": "->"
        },
        {
            "args": [
                {}
            ],
            "class": "Zend\\Mvc\\Controller\\AbstractRestfulController",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zfcampus/zf-rest/src/RestController.php",
            "function": "onDispatch",
            "line": 332,
            "type": "->"
        },
        {
            "args": [
                {}
            ],
            "class": "ZF\\Rest\\RestController",
            "function": "onDispatch",
            "type": "->"
        },
        {
            "args": [
                [
                    {},
                    "onDispatch"
                ],
                {}
            ],
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
            "function": "call_user_func",
            "line": 444
        },
        {
            "args": [
                "dispatch",
                {},
                {}
            ],
            "class": "Zend\\EventManager\\EventManager",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
            "function": "triggerListeners",
            "line": 205,
            "type": "->"
        },
        {
            "args": [
                "dispatch",
                {},
                {}
            ],
            "class": "Zend\\EventManager\\EventManager",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php",
            "function": "trigger",
            "line": 118,
            "type": "->"
        },
        {
            "args": [
                {},
                {}
            ],
            "class": "Zend\\Mvc\\Controller\\AbstractController",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php",
            "function": "dispatch",
            "line": 300,
            "type": "->"
        },
        {
            "args": [
                {},
                {}
            ],
            "class": "Zend\\Mvc\\Controller\\AbstractRestfulController",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/DispatchListener.php",
            "function": "dispatch",
            "line": 93,
            "type": "->"
        },
        {
            "args": [
                {}
            ],
            "class": "Zend\\Mvc\\DispatchListener",
            "function": "onDispatch",
            "type": "->"
        },
        {
            "args": [
                [
                    {},
                    "onDispatch"
                ],
                {}
            ],
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
            "function": "call_user_func",
            "line": 444
        },
        {
            "args": [
                "dispatch",
                {},
                {}
            ],
            "class": "Zend\\EventManager\\EventManager",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-eventmanager/src/EventManager.php",
            "function": "triggerListeners",
            "line": 205,
            "type": "->"
        },
        {
            "args": [
                "dispatch",
                {},
                {}
            ],
            "class": "Zend\\EventManager\\EventManager",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/vendor/zendframework/zend-mvc/src/Application.php",
            "function": "trigger",
            "line": 314,
            "type": "->"
        },
        {
            "args": [],
            "class": "Zend\\Mvc\\Application",
            "file": "/home/czeeb/git/zf-apigility-skeleton-1.1.1/public/index.php",
            "function": "run",
            "line": 51,
            "type": "->"
        }
    ],
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}

I'm using the built in php development server, called with php -S 0.0.0.0:8888 -t public public/index.php

czeeb commented 9 years ago

If I follow the documentation I get the following:

$ curl --silent -XPOST -H 'Content-Type: application/json'  localhost:8888/apigility/api/module/DoctrineExample/rest --data '{"objectManager":"doctrine.entitymanager.orm_default","serviceName":"Planet","entityClass":"Db\\Entity\\Planet","routeIdentifierName":"planet_id", "entityIdentifierName":"id", "routeMatch":"/api/planet"}' | python -m json.tool
{
    "detail": "Failed Validation",
    "status": 422,
    "title": "Unprocessable Entity",
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    "validation_messages": {
        "service_name": "You must provide either a Code-Connected service name OR a DB-Connected database adapter and table name"
    }
}