Serializer
openapi-psr7-validator
Serializer | openapi-psr7-validator | |
---|---|---|
9 | 7 | |
2,302 | 501 | |
- | 0.8% | |
7.9 | 4.8 | |
about 2 months ago | 11 days ago | |
PHP | PHP | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Serializer
- Data-Mapper: A package for fast mapping of strong-typed objects
- brick/json-mapper: map JSON data to strongly typed PHP DTOs
-
Design Decisions: Why use final classes
Making a class "final" is always a bad decision IMO. You would never know how will other people use your library. For example, we used JMSSerializerBundle and wanted to extend DateHandler to make it not to throw exceptions if a date string is invalid. But the class is final. So we had to just copy-paste it :(
- Symfony serializer is tedious
-
Array -> Entity
Or this popular alternative: https://jmsyst.com/libs/serializer
-
PHP libraries and tools
JMS Serializer: This library allows you to (de-)serialize data of any complexity. Currently, it supports XML and JSON.
-
Yet another Data-Transfer-Object package
Only took a very brief look, but it looks nice. I like that the DTO class isn't required to extend anything, and that it seems to be for real DTOs used for actual transfer of data between systems - not 'local dtos'. It feels like this might be more comparable to something like schmittjoh/serializer rather than spatie/data-transfer-object.
-
PHP foreach loop to XML
When it's time to create the PDF, convert the object structure to an XML using an already existing serializer (like JMS or symfony serializer) or do this by hand.
-
Is there a better way to connect to an API?
One frequently used serializer is JMS Serializer which allows you to convert JSON or XML to objects (or the other way around if needed). You can then use the objects in your application.
openapi-psr7-validator
-
Testing an OpenAPI specification in PHP
There is a package within The PHP League that allows validation of an OpenAPI specification: league/openapi-psr7-validator. This package validates requests and responses to the PSR-7 specification.
-
Generate POPO models from OpenApi specification
- https://github.com/thephpleague/openapi-psr7-validator for validation
-
Introduce Raven, a tool to tests your code against an OpenAPI definition !
how does this compare with https://github.com/thephpleague/openapi-psr7-validator
-
Validate your PHP API tests against OpenAPI definitions – a Laravel example
One tool destined for the PHP community and maintained by The PHP League is OpenAPI PSR-7 Message Validator, a package validating PSR-7 HTTP messages against OpenAPI definitions.
-
Do you use open api specs?
Request validation in a middleware layer using thephpleague/openapi-psr7-validator that allows us to validate 99% of an incoming request without the need for boilerplate checks in our handlers/controllers. Business specific checks will still need to be handled in the handler/controller though: eg, make sure user email is unique or validate account ID is still active, etc.
-
PHP libraries and tools
OpenAPI PSR-7 Message (HTTP Request/Response) Validator: It validates PSR-7 messages (HTTP request/response) against OpenAPI specifications.
-
On using PSR abstractions — Matthias Noback
And, imagine my surprise, even a Symfony-dedicated lib that does the same under the hood: https://github.com/thephpleague/openapi-psr7-validator
What are some alternatives?
Fractal - Output complex, flexible, AJAX/RESTful data structures.
Symfony - The Symfony PHP framework
JsonMapper - Map nested JSON structures onto PHP classes
PHP-DI - The dependency injection container for humans
data-transfer-object - Data transfer objects with batteries included
swagger-php - A php swagger annotation and parsing library
Ardent - A Collections library for PHP.
phpstan-rules - 👓 Provides a composer package with rules for phpstan/phpstan.
Arrayy - 🗃 Array manipulation library for PHP, called Arrayy!
L5-Swagger - OpenApi or Swagger integration to Laravel
CRUDlex - CRUDlex is an easy to use CRUD generator for Symfony 4 and Silex 2 which is great for auto generated admin pages
Deptrac - Keep your architecture clean.