2

I want to start using Zend_Rest_Controller for my app, and have set up the routing like so in my bootstrap:

protected function _initRestfulRoutes()
{
    $front = Zend_Controller_Front::getInstance();
    $router = $front->getRouter();

    // Specifying all controllers as RESTful:
    $restRoute = new Zend_Rest_Route($front);
    $router->addRoute('default', $restRoute);
}

However, when using Zend_Navigation, all routes will default to index action. My routes are defined like so:

    <users>
        <label>Users</label>
        <controller>users</controller>
        <action>index</action>
        <route>default</route>
        <pages>
            <delete>
                <label>Delete Me</label>
                <controller>users</controller>
                <action>delete</action>
                <id>1</id>
                <route>default</route>
            </delete>
        </pages>
    </users>

The delete route resolves as http://myapp.com/users instead of http://myapp.com/users/1?_method=DELETE

Any idea what's going on? Thanks.

2
  • If you have a URI that says .../?method=delete you are not doing REST. Commented May 4, 2010 at 19:00
  • There a reference to that format of URL here: framework.zend.com/manual/en/zend.controller.router.html Honestly I don't know enough about ZF's REST imeplmentation to understand how we're supposed to differentiate between post, put and delete in forms or URLs. But thanks for taking the time to school me on RESTfulness. Commented May 4, 2010 at 21:36

1 Answer 1

2

Zend_Rest_Route will not route to the "deleteAction()" based on a GET request. In order to invoke "deleteAction", you'll need to send a POST request with _method=DELETE in the body of the request.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.