Download the PHP package check24/apitk-dtomapper-bundle without Composer

On this page you can find all versions of the php package check24/apitk-dtomapper-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 apitk-dtomapper-bundle

apitk-dtomapper-bundle - DTO handling

Overview

This bundle adds versioned DTO support for RESTful API's.

Installation

Install the package via composer:

Usage

Setup

Add this to your services.yaml so the bundle can automatically load and use the mapper services:

Writing Mappers

Create a mapper class in the folder src/DtoMapper (or whichever you configured) which implements the MapperInterface and transforms incoming data into a single DTO:

In your controller replace the @Rest\View() annotation with the corresponding @Dto\View() mentioning the mapper to use:

The bundle now automatically transform whatever you return in the action with the help of the given mapper into an DTO. When you return an array of data in your controller, the mapper will be called on every single element. You don't have to worry about that.

You can throw a UnmappableException if you want to skip some elements of the array.

Also the bundle auto generates a swagger response with code 200 and the corresponding DTO scheme (respectively an array of DTOs), so you don't have to add the redundant @SWG\Response(). For this to work, just take care that your Mapper has a correct return typehint (f.e. public function map($data): FoobarDto) and that your controller action has a return annotation, which states if an array or object is returned (f.e. * @return Foobar[]). You can still overwrite this by your own @SWG\Response() annotation.

Turning arrays into Collections

If you return an array in the controller it will be serialized like this. If you do not want to work with an array or can not work with arrays due to technological constraints (protobuf) you can instruct the bundle to turn arrays into collection-classes instead.

To turn an array returned from a controller into a collection, implement the MapperCollectionInterface additionally to the MapperInterface into your mapper.

Example:

This will cause the bundle to call mapCollection as soon as all items have been mapped via map. You can initialize your collection class within the mapCollection method. The object returned here will replace the controller response's content.

Serialized DTO view

If you wish to return the DTOs in a serialize($dto) manner instead of json, implement the available dto view handler.

When calling the API with the Accept: application/vnd.dto header, you will get the DTO as an unserializable string.

Exceptions will also be serialized. Stack Traces, filenames, line numbers and previous exceptions will be omitted when kernel.debug is set to false (= in productive environments) to avoid leaking potentially sensitive information.

Serialized Protobuf view

If you wish to return serialized Protobuf object.


All versions of apitk-dtomapper-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
symfony/config Version >= 5.3 <6.0
symfony/dependency-injection Version >= 5.3 <6.0
symfony/http-kernel Version >= 5.3 <6.0
symfony/serializer Version >= 5.3 <6.0
symfony/framework-bundle Version >= 5.3 <6.0
doctrine/annotations Version ^1.6
nelmio/api-doc-bundle Version ^3.2
check24/apitk-common-bundle Version ^2.2 || ^3.0
friendsofsymfony/rest-bundle Version ^3.0
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 check24/apitk-dtomapper-bundle contains the following files

Loading the files please wait ....