solve-x / view-model
A more structured way of processing requests (inspired by ASP.NET)
v0.1.11
2017-09-29 09:55 UTC
Requires
- doctrine/annotations: 1.4
- illuminate/translation: ^5.4
- nesbot/carbon: 1.22.1
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: 5.2
This package is not auto-updated.
Last update: 2025-04-13 05:44:32 UTC
README
Model validation in ASP.NET Core MVC
Note: this library is still in beta. We might make incompatible changes until version 1.
A short example:
<?php namespace App\ViewModels; use SolveX\ViewModel\ViewModel; class RegistrationViewModel extends ViewModel { /** * @var string */ public $FirstName; /** * @var int */ public $Age; }
<?php namespace App\Controllers; use App\ViewModels\RegistrationViewModel; class UserController { public function register(RegistrationViewModel $model) { // At this point $model is ready to use. // In case binding or validation fails, an exception is thrown during model construction. // $model->FirstName // $model->Age } }