Skip to content

Updated Zend Framework 2 Modules because of the locator generator version 2.0.0 release

I announced already, version 2.0.0 of the "locator generator" is out.
Because of that, I am also happy to announce the release of 1.4.1 from the zend framework 2 "locator generator" module.
Furthermore, the debian 6/PHP 5.3 backport got the release of version 1.3.0.
And finally, and because of the fact that zend framework 2.5.* is dropping support for PHP 5.4, the new debian 7/PHP 5.4 got the release of version 1.7.0.
Major changes in all releases is the dependency update to the new locator generator version.

You want to have a quick look and tryout without any hassle? Try the zf demo environment available in three flavors, cutting edge, debian 7/PHP 5.4 backport and debian 6/PHP 5.3 backport.

Translate to de es fr it pt ja

php - zfcampus/zf-rest how to | tutorial

Assuming you are using the Zend Framework 2 and want to implement a REST endpoint in a quick and fully functional way.
ZF-Rest is, more or less, the official rest module for zf2. But, the documentation is not available - nor planned right now. Thats why I this blog entry will boost your knowledge and speed up the time until you have finished your first zf2 rest endpoint.

Installation and Setup


#add the following line to you composer.json
"zfcampus/zf-rest": "1.0.3"

You need to add the following entries in your to "config/autload/application.config".


 array(
        //your modules
        'ZF\ApiProblem',
        'ZF\ContentNegotiation',
        'ZF\Hal',
        'ZF\MvcAuth',
        'ZF\OAuth2',
        'ZF\Rest'
    );

Minimal Configuration (module.config.php)

array key "zf-rest"


//MyRestController is a virtual Controller 
'My\\Module\\Namespace\\MyRestController' => array(
    //mandatory - available are GET, POST, PUT, PATCH, DELETE
    'collection_http_methods'       => array(
        'GET'
    ),
    //mandatory - available are GET, POST, PUT, PATCH, DELETE
    'entity_http_methods'           => array(
        'GET'
    ),
    //virtual name - its the name the collection entries are getting in the HAL-repesentation
    'collection_name'               => 'items',
    'route_name'                    => 'my_rest_route_name',
    'route_identifier_name'         => 'id',
    //this is the only file you really need to code/implement
    'listener'                      => 'My\\Module\\Namespace\\MyListener'
),

array key "router/routes"


'my_rest_route_name' => array(
    'type' => 'Zend\Mvc\Router\Http\Segment',
    'options' => array(
        'route' => '/my/rest/endpoint/[/:id]',
        'defaults' => array(
            //MyRestController is a virtual Controller
            //The name is needed to map the module configuration to the endpoint
            'controller' => 'My\\Module\\Namespace\\MyRestController'
        )
    ),

Optional Configuration Values

Based on the source code from RestControllerFactory.php, following configuration keys are optional (mention as mandatory in the current README.md).

  • resourceidentifiers
  • identifier
  • controllerclass
  • entityclass
  • collectionclass
Translate to de es fr it pt ja

version 1.0.2 of zend framework 2 console helper (debian 6 backport) released

I happy to announce the release of 1.0.2 of bazzlines zend framework 2 console helper (debian backport) module for php. Important changes are:

  • removed dependency to apigen
  • updated dependencies
Translate to de es fr it pt ja

version 1.3.3 of zend framework 2 locator generator released

I happy to announce the release of 1.3.3 of bazzlines zend framework 2 locator generator module for php. Important changes are:

  • updated dependencies
  • removed apigen dependency
  • fixed dependency issue
  • added factory for controller creation
  • updated to locator generator 1.4.0
  • added documentation @todo - add link
  • added migration
  • added link to debian 6 / zend framework 2.2 backport
  • prefixed console commands with "net_bazzline" to not pollute the available command environment
Translate to de es fr it pt ja