Download the PHP package crtl/request-dto-resolver-bundle without Composer

On this page you can find all versions of the php package crtl/request-dto-resolver-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package request-dto-resolver-bundle

crtl/request-dto-resolver-bundle

Symfony bundle for streamlined instantiation and validation of request DTOs.

Features

  1. Automatic DTO Handling:
    Instantly creates and validates Data Transfer Objects (DTOs) from Request data, that are type-hinted in controller actions.
  2. Symfony Validator Integration:
    Leverages Symfony's built-in validator to ensure data integrity and compliance with your validation rules.
  3. Nested DTO Support:
    Handles complex request structures by supporting nested DTOs for both query and body parameters, making it easier to manage hierarchical data.

Installation

Configuration

Register the bundle in your Symfony application. Add the following to your config/bundles.php file:

Usage

Step 1: Create a DTO

Create a class to represent your request data. Annotate the class with #[RequestDTO] and use bellow attributes for properties to map request parameters.

IMPORTANT
Each property must accept the type ?string except properties that are request DTOs.
Otherwise PHP may throw TypeErrors at runtime because we cannot know that the request contains the valid data type before validation.

By default, each parameter is resolved by its property name.
If property name does not match parameter name you can pass an optional string to the constructor of each *Param attribute (see AbstractParam::__construct).

Each DTO can define an optional constructor which accepts a Request object

Step 2: Use the DTO in a Controller

Inject the DTO into your controller action. The RequestValueResolver will automatically instantiate and validate the DTO.

Step 3: Handle Validation Errors

When validation fails, a Crtl\RequestDTOResolverBundle\Exception\RequestValidationException is thrown.

You can create an event listener or override the default exception handler and handle validation errors.

License

This bundle is licensed under the MIT License. See the LICENSE file for more details.


All versions of request-dto-resolver-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
symfony/http-kernel Version ^7.1
symfony/validator Version ^7.1
psr/log Version ^3.0
symfony/dependency-injection Version ^7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package crtl/request-dto-resolver-bundle contains the following files

Loading the files please wait ....