Download the PHP package gocanto/relay without Composer

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

About it

Total Downloads Latest Stable Version Build status

Relay is a data transfer objects structure that allows you to consume third party API payloads and parse them into their proper type object throughout a promotion mapper to ensure given incoming data abides by its expected type.

How does it work?

Relay is a self-contained attribute bag that maps its values using promoters that parse given incoming payloads into valid data transfer objects. Thus, you will have the option to remove the ability to work with unstructured data in your application by using proper types through wrappers that take care of any sanitation and validation logic constraints.

What are promoters?

A promoter is a data structure that allows us to map given data with the desired data type. By doing so, we will be able to guard unknown payloads using proper types. For instance, you can specify that a first_name key value is the type text to prevent the transfer object from being created on constraints failures.

Furthermore, you will have the ability to mark keys value as Any if you are not sure of the data type it belongs to.

Case of study

Let's imagine we are consuming a third party API from an event platform to persist it in our database. Usually, you will be given users information such as email, name or profile URL. This is a pretty challenging case scenario since you will have to validate and sanitize the incoming payload to avoid having inconsistent data in your application.

Now, if you are anything like me, you might be thinking of parsing the incoming payload into an array, and then validate key-value by accessing the array and asking whether we have got the valid information. Such as:

As you can see here, this can go out hands pretty quickly for many reasons. To mention some, we could say the following:

Nevertheless, we are good programmers and like to do better. Furthermore, we love working with types don't we?

Using relay to handle your payloads.

after you have installed the relay data transfer in your application, you will be able to consume the above payload like so

Furthermore, you will be given an Any object wrapper if the asked payload key does not have a specified mapping or was marked as optional using the ::optional() construct method within the promoter object. See example

Note: Any key-value specified in your payload mapper is marked as required

If you would like to know more about the functionality and different uses, please click on here.

Supported types

To learn more about their functionality, you can click on the following links:

Future scopes.

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance its functionality.

License

The MIT License (MIT). Please see License File for more information.

How can I thank you?

Why not star the github repo and share the link for this repository on Twitter?

Don't forget to follow me on twitter!

Thanks!

Gustavo Ocanto.


All versions of relay with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
ext-json Version *
nesbot/carbon Version ^2.32
symfony/validator Version ^5.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 gocanto/relay contains the following files

Loading the files please wait ....