phprest/phprest-service-validator

Phprest Validator Service.

Installs: 883

Dependents: 3

Suggesters: 3

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/phprest/phprest-service-validator

dev-master 2015-06-29 10:34 UTC

This package is not auto-updated.

Last update: 2025-09-27 21:10:40 UTC


README

Author Software License

Description

Validator Service which uses the Symfony\Validator component.

Installation

Install it through composer.

{
    "require": {
        "phprest/phprest-service-validator": "@stable"
    }
}

tip: you should browse the phprest/phprest-service-validator page to choose a stable version to use, avoid the @stable meta constraint.

Usage

Configuration

For the configuration you should check the Config class.

Registration

use Phprest\Service\Validator;
# ...
/** @var \Phprest\Application $app */

$app->registerService(new Validator\Service(), new Validator\Config());
# ...

Reaching from a Controller

To reach your Service from a Controller you should use the Service's Getter Trait.

<?php namespace App\Module\Controller;

use Phprest\Service;

class Index extends \Phprest\Util\Controller
{
    use Service\Validator\Getter;

    public function post(Request $request)
    {
        $this->serviceValidator()->validate(...);
    }
}

Utils

Most of the Services in Phprest provides some utility mechanism (helper functions).

For the utilities you should check the Util class.