GithubHelp home page GithubHelp logo

zf2-restful-module-skeleton's Introduction

ZF2 Restful Module Skeleton

This module skeleton provides foundation for working with the ZF2 Restful controller.

To learn how to setup Zend Framework 2 click here. Once setup, you can clone and place this skeleton under the "module/Main" folder. You will also have to change your project's config file (application.config.php) to include this module:

		...
		'modules' => array(
			...
			'Main',
			...
		),
		...
	

Example URI implementations included:

  • /info.json - Loads InfoController::getList() and renders through PostProcessor/Json.php

Suggestions

In an effort to make this module better, I encourage you to submit any API or REST related feature requests in the "Issues" section.

zf2-restful-module-skeleton's People

Contributors

getfokus avatar redbeardmedia avatar scaraveos avatar taisph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zf2-restful-module-skeleton's Issues

Fatal error

When I tryt o use your module in latest Zend Framework and Skeleton Application I get this error

error

getVariables() method issue

Thanks for this great restful example. But it seems the module.php has some problem based on ZF2 beta 3 when request category.json and thumb.json, as for these two controllers, their getList is returned an array, but not ViewModel. $e->getResult()->getVariables() doesn't work.
So in my local, the fixture is:
Module.php (Line 53)
$vars = $e->getResult();
if($vars instanceof \Zend\View\Model\ViewModel)
{
$vars = $e->getResult()->getVariables();
}
$postProcessor = $di->get($formatter . '-pp', array(
'vars' => $vars,
'response' => $e->getResponse()
));

Service with name "json-pp" could not be created.

Hi ,

We are upgrading laminas 3 from laminas 2 and we are getting below error,

[Thu Jun 16 00:45:33.497009 2022] [php:notice] [pid 29] [client 172.17.0.1:41805] Exception: Service with name "json-pp" could not be created. Reason: Could not resolve value for parameter "vars" of type any in class Shipwire\\ApiClient\\PostProcessor\\Json (requested as json-pp) --- Backtrace: #0 /var/www/shipwire.www/swclient/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(234): Laminas\\ServiceManager\\ServiceManager->doCreate()\n#1 /var/www/shipwire.www/swclient/module/Main/Module.php(793): Laminas\\ServiceManager\\ServiceManager->get()\n#2 /var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Main\\Module->errorProcess()\n#3 /var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php(171): Laminas\\EventManager\\EventManager->triggerListeners()\n#4 /var/www/shipwire.www/swclient/vendor/laminas/laminas-mvc/src/DispatchListener.php(146): Laminas\\EventManager\\EventManager->triggerEvent()\n#5 /var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\\Mvc\\DispatchListener->onDispatch()\n#6 /var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php(179): Laminas\\EventManager\\EventManager->triggerListeners()\n#7 /var/www/shipwire.www/swclient/vendor/laminas/laminas-mvc/src/Application.php(325): Laminas\\EventManager\\EventManager->triggerEventUntil()\n#8 /var/ww

This module does not work with ZendDeveloperTools

I have installed ZendDeveloperTools using
"php composer.phar require zendframework/zend-developer-tools:dev-master"

Once I enable ZendDeveloperTools in configuration file. it throws error
Fatal error: Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter driver for Zend\Db\Adapter\Adapter::__construct'

if I disable ResetModule, Developer tool works fine and vise versa. It seems there is some conflict between ZendDeveloperTools and ZF2-Restful-Module-Skeleton

Support for longer (or more complex) URLs

Hi,

I am looking into supporting more fine-grained URLs, for example like the Twitter API:

statuses/mentions_timeline
statuses/user_timeline

Is this something you can help me with or point me in the right direction?

Regards,

Daan

Question about posible reason not function

I changed standard skeleton structure. Now index.php is not in public directory. It is like this

config
data
module
|--Application
|--Main
`--other apps..
themes
|--desktop
|  `--default
`--mobile
   `--default
vendor
index.php

There are number of reasons why I did it and it is not an issue. But in this structure if I try /info.json gives apache 404 error. Not Zend Skeleton 404. In the issue I submitted previously the structure is standard.

So, do you know any reason why it may not work? Can index.php replacement to influence it?

Because Application module works ok and other modules seems to work too.

You know what I actually need is Zend restful application skeleton. not a simple module but embedded it in to skeleton so the whole skeleton turn into resftul service.

Response format in URI

To be a true restful module the format doesn't need to appear in the URL.

It would be better to use the "HttpAcceptStrategy" to to send the quering format.

Error Processor takes over all application, not just Rest Module

Hey guys, is there a different listener that I could attach the error processor to so that this can be added as a Module of an app instead of the whole application?

As it is right now the error processor gets dispatched regardless of which module the error occurred in.

Extra data when issueing Status Code

When using REST, you would like to get the return status codes right. But if I give a 404 when an object isn't found

$this->getResponse()->setStatusCode(\Zend\Http\PhpEnvironment\Response::STATUS_CODE_404);

I get this data returned as well:

message: "Page not found.",
reason: "error-controller-cannot-dispatch",
controller: "tld",
controller_class: null

Is there another way I should invoke the status codes?

unable to fetch or create an instance for info

Hello,

I tried to add this module to the ZF2 Skeleton Application, using the latest pull from the zf2 repo (two days ago) but when I tried to access /info.json I got this error:

"Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for info

In addition, to make it work I had to change the ->headers() call in the JSON postprocessor to ->getHeaders() to match the current state of the Framework.

I am rather new at ZF2 so any suggestion/fix would be greatly appreciated as this skeleton module is the closest thing I came to seeing the RestfulController work.

Regards!

Missing instance/object for parameter route for Zend\Mvc\Router...

Hi
I have just installed the ZF2 Skeleton Application and cloned your module to module/Main, and added 'Main' to config/application.config.php

But when I go to the URL's
http:///
http:///info.json

I get the error below.

Can you tell me how to fix this?

Thanks
Rob

Fatal error: Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter route for Zend\Mvc\Router\Http\Literal::__construct' in /www/Zend/vendor/zendframework/zendframework/library/Zend/Di/Di.php:699 Stack trace: #0 /www/Zend/vendor/zendframework/zendframework/library/Zend/Di/Di.php(393): Zend\Di\Di->resolveMethodParameters('Zend\Mvc\Router...', '__construct', Array, NULL, true, true) #1 /www/Zend/vendor/zendframework/zendframework/library/Zend/Di/Di.php(225): Zend\Di\Di->createInstanceViaConstructor('Zend\Mvc\Router...', Array, NULL) #2 /www/Zend/vendor/zendframework/zendframework/library/Zend/Di/Di.php(174): Zend\Di\Di->newInstance('Zend\Mvc\Router...', Array, true) #3 /www/Zend/vendor/zendframework/zendframework/library/Zend/ServiceManager/Di/DiServiceFactory.php(104): Zend\Di\Di->get('Zend\Mvc\Router...', Array) #4 /www/Zend/vendor/zendframework/zendframework/library/Zend/ServiceManager/Di/DiAbstractServiceFactory.php(43): Zend\ServiceManager\Di\DiServiceFactory in /www/Zend/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 749

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.