This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Zend\Mvc\Router\RouteMatch; | |
// A listener on dispatch.error, for instance. | |
$listener = function ($e) { | |
$app = $e->getTarget(); | |
$sm = $app->getServiceManager(); | |
$dispatch = $sm->get('DispatchListener'); | |
$event = clone $e; | |
$routeMatch = new RouteMatch(array('controller' => 'Some\Controller\Alias')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"autoload": { | |
"psr-0": { | |
"Application": "module/Application/src" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Zend\Form\Annotation; | |
class Foo | |
{ | |
/** | |
* @Annotation\Type("Zend\Form\Element\Radio") | |
* @Annotation\Options({"label": "Your Choice:", "value_options":{"foo":"bar", "bar":"baz"}}) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We rename "master" to "develop" | |
We rename "release" to "master" | |
Thus "master" stays the default branch, which means most PRs will be made | |
against it. | |
Bugfixes are merged to: | |
- master | |
- develop | |
Features are merged to: | |
- develop | |
When develop looks like the next minor or major version: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace My\Api\V1; | |
use Zend\ServiceManager\AbstractFactoryInterface; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
class AbstractControllerFactory implements AbstractFactoryInterface | |
{ | |
protected $allowedControllers = array( | |
'user', | |
'group', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'router' => array('routes' => array( | |
'api' => array( | |
'type' => 'Segment', | |
'options' => array( | |
'route' => '/api/v1/:controller[/:id]', | |
'defaults' => array( | |
'__NAMESPACE__' => 'Api\V1\Controller', | |
'controller' => 'User', // just an example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My; | |
class Module | |
{ | |
public function onBootstrap($e) | |
{ | |
$events = $e->getTarget()->getEventManager(); | |
$events->attach('route', array($this, 'onRoutePost'), -100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== RESTful Services Made Easy with ZF2 == | |
Need a web service? Befuddled by WSDL? Does the lack of object support in | |
XML-RPC limit what you can do? Do you want to use your service with JavaScript? | |
Would you like to rely on native browser and client caching of your services? | |
REST is an alternative, capable of addressing all of these needs. | |
During this tutorial, we'll look at various aspects of REST, including proper | |
use of HTTP methods, the usage of media types, approaches to content | |
negotiation, and hyperlinking -- all the pieces necessary to build a good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Helper | |
{ | |
public static function createHash(Paste $paste, PasteService $service) | |
{ | |
$seed = $paste->language . $paste->timestamp . $paste->content; | |
do { | |
$seed . = uniqid(); | |
$hash = hash('sha1', $seed); | |
} while ($service->exists($hash)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My; | |
class Module | |
{ | |
public function getServiceConfig() | |
{ | |
return array( | |
'initializers' => array( | |
function ($instance, $services) { |