scaraveos / zf2-restful-module-skeleton Goto Github PK
View Code? Open in Web Editor NEWA Zend Framework 2 module skeleton that works with the RestfulController
A Zend Framework 2 module skeleton that works with the RestfulController
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
Would be nice if it were Composer friendly.
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.
Cloned latest ZF2, cloned this module to /modules/Main, added the module to application config.
It's not working for me. Other modules work just fine.
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.
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!
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?
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
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
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.
Do you have any good example of unit test for each controller ?
Thanks in advance :)
what would be the right solution, if I would like to implement another get method here, https://github.com/scaraveos/ZF2-Restful-Module-Skeleton/blob/master/src/Main/Controller/InfoController.php but parameter will be different?
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()
));
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.