Download the PHP package dbstudios/php-api-common without Composer

On this page you can find all versions of the php package dbstudios/php-api-common. 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 php-api-common

This package contains components that tend to be useful across different REST API projects.

This package is broken up into several parts:

Common

Common files include the ResponderInterface and it's implementations, as well as the classes in the top level of the src/Error/Errors directory.

Working with responders is pretty straightforward.

The above code returns a Response object containing the following JSON.

Responders can also be used to simplify error handling, and to normalize error response formats.

The above code returns a Response object containing the following JSON.

For Symfony projects, you can use DaybreakStudios\RestApiCommon\ResponderService instead, which takes a responder and the request stack, allowing you to omit the format argument in calls to ::createResponse() and createErrorResponse().

Validation

The validation component adds an extra API error class, which will normalize constraint violation errors from the symfony/validator component, allowing them to nicely returned as an API error.

The above code returns a Response object containing approximately the following JSON.

Doctrine Query Document

The Doctrine query document component adds 4 new API error classes. Since they're relatively simple, please refer to the individual class documentation.

Lexik JWT

The Lexik JWT component adds a special event subscriber that will transform the very generic error messages emitted by the lexik/jwt-authentication-bundle into messages that can be displayed directly to the end-user.

To register the subscriber in a Symfony application, be sure to add the kernel.event_subscriber tag to the service!

Payload

The payload component adds a simple framework for parsing API payloads into Data Transfer Object (DTO) classes. While useful by itself, giving you a more concrete set of fields on the objects your API consumes, it is most useful when also paired with the symfony/validator package, giving you a clean way to validate input to your API. By default, assertions tagged with the "create" group will only be run when DecoderIntent::CREATE is passed to the parse() method, while assertions tagged with the "update" method will be run when DecoderIntent::UPDATE is passed. Assertions in the "Default" group will always run. For example:

In the above example, the final line's call to SymfonyDeserializeDecoder::parse() would result in an ApiErrorException, whose error field would be a ValidationFailedError, since the input payload did not pass validation (the email address was not a valid email address).

If you're using PHP 8, you can use the PayloadTrait in your DTO class to gain access to the exists() and unset() utility methods. Since PHP 8 introduces the mixed psuedo-type, you can use it as the actual type for the properties on your DTO class. By doing so, you can use the exists() method, which uses \ReflectionProperty::isInitialized() to determine if a property was actually part of the input payload, and not just defaulting to null because the key was not included. This is useful when you have a property that might be part of the payload, but whose value could be null (since isset() would still return false when used on such a property). Since exists() uses reflection, results are cached to mitigate performance hits due to repeated calls for the same property. Do not call unset() directly on any property of a DTO class that you might need to call exists() on; instead, use PayloadTrait::unset() to unset the property and clear it from the exists() cache.


All versions of php-api-common with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.2
ext-json Version *
symfony/serializer Version ^6.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 dbstudios/php-api-common contains the following files

Loading the files please wait ....