GithubHelp home page GithubHelp logo

Comments (2)

adamlundrigan avatar adamlundrigan commented on June 27, 2024

There's little in the way of documentation for or recent information on AbstractRestfulController so I did this: using the latest version of the skeleton, I added a route to the module config:

            'ping' => [
                'type' => Segment::class,
                'options' => [
                    'route'    => '/ping[/:id]',
                    'defaults' => [
                        'controller' => Controller\PingController::class,
                    ],
                ],
            ],

And added PingController:

<?php
namespace Application\Controller;

use Zend\Mvc\Controller\AbstractRestfulController;

class PingController extends AbstractRestfulController
{
    public function getList()
    {
        return [
            'now' => date(\DateTime::ISO8601)
        ];
    }
}

(and added that controller to the controller factory)

... and it's "working". I dump the RouteMatch from inside getList and I get this:

Zend\Router\Http\RouteMatch Object
(
    [length:protected] => 5
    [params:protected] => Array
        (
            [controller] => Application\Controller\PingController
        )

    [matchedRouteName:protected] => ping
)

However, I also get a Zend\View runtime exception:

Unable to render template "application/ping/get-list"; resolver could not resolve to a file

I added the ViewJsonStrategy to the view manager but still received the same error. Maybe this stopped working way back when renderer selection based on Accept header was removed from those strategies (PR)? Or maybe I'm just not configuring the controller properly. In either case, AbstractRestfulController probably should be updated to use AcceptableViewModelSelector.

A quick Google didn't turn up any recent articles or mentions of AbstractRestfulController. I suspect that people have long since moved on to packages like ZfrRest or zf-rest or even rolling their own (eg: zend-router can do routing based on HTTP Method)

from zend-router.

Xerkus avatar Xerkus commented on June 27, 2024

Router does not set parameters on its own, none of the zend-mvc versions have 'index' string either.
It is either from route configuration or some user registered listener in mvc application

from zend-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.