sebaks / zend-mvc-controller
Installs: 1 333
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=5.5
- sebaks/controller: ~0.1.0
- zendframework/zend-http: <2.6 >=2.4
- zendframework/zend-modulemanager: <2.6 >=2.4
- zendframework/zend-mvc: <2.6 >=2.4
- zendframework/zend-view: <2.6 >=2.4
Requires (Dev)
- phpunit/phpunit: ^4.8
- squizlabs/php_codesniffer: ^2.3
README
Zend MVC controller implementation
This is controller implementation for Zend MVC builds on sebaks/controller.
Most controllers must do
- Check if that controller\action can be accessed by called method (GET, POST, PUT etc.), if not - rise exception.
- Process request (this is responsibility of sebaks/controller).
- Validate request criteria.
- Validate request data.
- Process request (run any domain service).
- Collect errors.
- Collect result.
- Rise exceptions if error exists.
- Redirect to next page (if define).
- Setup ViewModel.
- Setup MVC Event.
That solution allow to customize any flow parameter and increases code reuse.
Installation
-
Install it via composer by running:
composer require sebaks/zend-mvc-controller
-
Copy
./vendor/sebaks/zend-mvc-controller/config/sebaks-zend-mvc-controller.global.php.dist
to./config/autoload/sebaks-zend-mvc-controller.global.php
.
Configuration
You can configure that controller with route params:
'router' => [ 'routes' => [ 'user-update-profile' => [ 'type' => 'Segment', 'options' => [ 'route' => '/profile/update', 'defaults' => [ 'controller' => 'sebaks-zend-mvc-controller', 'allowedMethods' => ['POST'], 'criteriaValidator' => Users\Action\Profile\CriteriaValidator::class, 'changesValidator' => Users\Action\Profile\ChangesValidator::class, 'service' => Users\Action\Profile\Updater::class, 'request' => Sebaks\Controller\RequestInterface::class, 'routeCriteria' => 'id' 'response' => Sebaks\Controller\ResponseInterface::class, 'redirectTo' => 'admin-user-list', 'viewModel' => Users\User\ViewModel::class, ], ], ], ], ],
criteriaValidator
, changesValidator
- if not defined, will be created Sebaks\Controller\EmptyValidator
service
- if not defined, will be created Sebaks\Controller\EmptyService
request
- if not defined, will be created Sebaks\Controller\Request
response
- if not defined, will be created Sebaks\Controller\Response
viewModel
- if not defined, will be created Zend\View\Model\ViewModel