openapi-httpfoundation-testing-laravel-example
Nyholm PSR-7
openapi-httpfoundation-testing-laravel-example | Nyholm PSR-7 | |
---|---|---|
1 | 7 | |
3 | 1,122 | |
- | - | |
3.3 | 3.7 | |
11 months ago | 20 days ago | |
PHP | PHP | |
- | 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.
openapi-httpfoundation-testing-laravel-example
-
Validate your PHP API tests against OpenAPI definitions – a Laravel example
The code featured in this section is also available as a GitHub repository for reference.
Nyholm PSR-7
-
Testing an OpenAPI specification in PHP
As the documentation states, this package only performs the conversion, so we would need a PSR-7 and a PSR-17 implementation to convert the objects to and from PSR-7. We can use the library the documentation recommends, nyholm/psr7, but there are others.
-
Creating an application #9 - http Factories
The following example shows how to create configuration for the HTTP factories, using the nyholm/psr7 package:
-
The PHPer's Guide to OAuth
Since the library is designed to be easily integrated with different frameworks, it relies on the usage of PSR-7 compliant HTTP messages. To fulfill this requirement, I'll be using the nyholm/psr7 package.
-
Decorator pattern implementing interface
If you go strict PSR-7, as you see in nyholm/psr7, Tobias uses traits to add the functionality of the extended RequestInterface and MessageInterface:
-
Validate your PHP API tests against OpenAPI definitions – a Laravel example
The Symfony folks thought of this, however, and provided a bridge that converts HttpFoundation objects to PSR-7 ones. The bridge simply needs a PSR-7 and PSR-17 factory, for which they suggest to use Tobias Nyholm's PSR-7 implementation.
-
re: On using PSR abstractions
“In theory, theory and practice are the same. In practice, they are not.” (Dr. Albert Einstein). I believe same goes for packages, too. A good example is the [comparison](https://github.com/Nyholm/psr7) of some PSR-7 implementations.
-
Introducing FEAST Framework
The point is why would I pull in code in the first place that is not needed? If it is optional, then why is it not a separate package? Same with all of the bloated HTTP requests and response objects that frameworks and other libs usually use. I really like https://github.com/Nyholm/psr7 for that reason, it has a table in it's readme.md that is pretty much enough to know why I like it. If something specific is needed it can be decorated or extended on project level.
What are some alternatives?
openapi-httpfoundation-testing - Validate your HttpFoundation requests and responses against OpenAPI (3+) definitions
Laminas Diactoros - PSR HTTP Message implementations
L5-Swagger - OpenApi or Swagger integration to Laravel
psr17 - Provides a PSR17 synthetic implementation.
scramble - Modern Laravel OpenAPI (Swagger) documentation generator. No PHPDoc annotations required.
swagger-php - A php swagger annotation and parsing library
fluentpdo - A PHP SQL query builder using PDO
Packagist - Package Repository Website - try https://packagist.com if you need your own -
Laravel - Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.
psr-http - PSR-7, 15, 17 implementation.
php-http-header-response - A simple package to send HTTP header responses ✨
Phalcon - High performance, full-stack PHP framework delivered as a C extension.