Download the PHP package markhuot/data without Composer

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

Simple data objects

Data (or value) objects can be used to represent data that may not otherwise have a strict class in your application. For example, POST data coming from a web request or JSON data coming from an API call. In these situations you may want a strongly typed version of the data but not want to write all the boilerplate to cast the data from the source to your data object.

This package handles all that boilerplate for you and aims to cover 80% of the most common use cases with the ability to extend the package should you need more specific transformations.

At it's most basic level the package is a transformer from your source representation (usually loosely typed) in to the target representation (more strongly typed). It looks like this (seriously).

The goal of this package is to be able to layer this package on top of your existing data objects without needing much (if any) customization. It works off attribute labels and tries to infer as much through convention as possible.

To convert source data in to your data object you'll call ->fill($data) on the data builder.

When you call ->fill($data) the package will use introspection to determine how the source $data maps to the properties in the Repository object. By default there is no mapping and it will blindly look for source fields like id and push them in to the destination property of ->id.

When the mapping is not 1:1 and you need to more control over the field naming you can use the MapFrom attribute to help the transformer along.

That will pull the full_name field from the source and drop it in to the ->fullName property in the destination. If your conversion is snake case to camel case there is a convent helper to do just that,

If you find yourself using identical MapFrom annotations several times over you can also apply the attribute to the class to have all property names converted in the same way,

In example all fields in the Repository class will be converted during transformation. id will remain ->id, name will remain ->name but full_name will automatically map to ->fullName.

Nested maps

By default nested properties will be mapped based on the type hint. The typehit can either come from PHP or the docblock depending on your needs. For single object nesting you can use native PHP type hints like this,

This will map the source data ['owner' => ['id' => 1, 'login' => 'foo']] over to a Repository with an ->owner property that is correctly set to an Owner instance with ->id and ->login set on the Owner instance.

For more advanced mappings you can use a docblock to define properties that PHP doesn't yet understand. For example,

This will correctly read that ->assets expects to be an array of assets and will try to transform the source in to an array of objects. It would work with the following source data,

Validation

Because many times strict typing isn't enough to ensure the data is correct you can also use the Symfony validation component to validate the data after the ->fill() process.


All versions of data with dependencies

PHP Build Version
Package Version
Requires pestphp/pest Version ^1.22
illuminate/collections Version ^8|^9.36
phpdocumentor/reflection-docblock Version ^5.3
symfony/validator Version ^5|^6.1
symfony/string Version ^5|^6.1
doctrine/annotations Version ^1.13
symfony/cache 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 markhuot/data contains the following files

Loading the files please wait ....