Download the PHP package piggly/php-payload without Composer

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

Payloads

Payloads, how name says, are about data. That tradicional model with getters and setters. But, we don't need models anymore. Thanks to (Eloquent Model)[https://laravel.com/docs/8.x/eloquent] which solved that.

But, there are still Request and Response data, they are not any kind of storage data, they are just data. Adopt some kind of ORM Model to them... it's kind of overthinking, making these datas too complex.

This simples library cames to solve it. Payloads are tradicional arrays with more flexibily. Same flexibility we can see at Eloquent Models, but not complicated or overpowerfull at all. It's just a way to standatize dataa across Requests and Responses.

See below how it works.

PayloadArray

The Person object:

The Address object

Usage

PayloadMap

The PayloadMap class force to payload use a map. This mapping will strict define all fields allowed to payload and, even, fields validations. Each field inside a PayloadMap will be a Field object. The Field object will have following properties:

Method Description
getKey() Field key name.
exportKeyAs() and getKeyToExport() Alias to field key name while exporting. (e.g. A field country may be exported as country_id).
value() and getValue() Field value.
label() and getLabel() Field label.
defaults() and getDefault() Field default value.
required(), optional() and isRequired() If field is required or optional.
acessible(), hidden() and isAcessible() If field is accessible or hidden.
allowsNull(), notAllowsNull() and isAllowingNull() If NULL is a valid value for field and it should accept it for exporting. (e.g. if country does not allows NULL and country is NULL, then it won't be exported).
validator() A Respect\Validation\Validator object to validate field value.
custom() and getCustom() To manager custom properties.

There also methods:

Creating a PayloadMap works the same way as creating a PayloadArray, but it's required the _map() method, which will contains the mapping to fields:

You may use setter{key}() and getter{key}() methods to mutate field value before set and after get. Mutators, be them setters or getters, should always return the value mutated.

Changelog

See the CHANGELOG file for information about all code changes.

Testing the code

This library uses the PHPUnit. We carry out tests of all the main classes of this application.

Contributions

See the CONTRIBUTING file for information before submitting your contribution.

Credits

Support the project

Piggly Studio is an agency located in Rio de Janeiro, Brazil. If you like this library and want to support this job, be free to donate any value to BTC wallet 3DNssbspq7dURaVQH6yBoYwW3PhsNs8dnK ❤.

License

MIT License (MIT). See LICENSE.


All versions of php-payload with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.0
respect/validation Version ^2.2
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 piggly/php-payload contains the following files

Loading the files please wait ....