Download the PHP package krak/marshal without Composer

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

Krak Marshal

A library for marshaling data with a functional design. This is useful for transforming/marshaling data for API output, un-marshaling and hydrating serialized data, or for any other types types of transforming.

Usage

Accessors

For certain marshalers, you'll want to marshal an entity in the form of the array or object. For that, we have accessors. An accessor implements the Krak\Marshal\Access interface.

usage:

Hydrators

Hydrators are used to marshal array data into an object. Each hydrator is any callable with the following interface

API

hydrate($class, $hydrator = null)

Creates a marshaler that will hydrate the data with the given $class parameter and forwards the $class and the $data from the marshaler to the $hydrator. If no hydrator is supplied, the default hydrator() will be used.

keyMap($map)

transforms the keys of the data into a new key

rename(array $map)

renames key fields into a new name

only(array $fields)

It only includes the given fields. Everything else is filtered out.

except(array $fields)

It includes all except the given fields. Everything else is kept.

filter(callable $filter)

Filters the collection via the filter func which has the signature $filter($value, $key): bool

dates($format = 'r')

Formats all instances of DateTimeInterface with the given format specifier.

objectVars()

Converts the properties of an object into an array. This is just an alias of get_object_vars.

typeCast(array $fields, $type)

Type casts the given fields into a specific type.

pipe($marshalers)

Creates a marshaler that pipes the result of one marshaler into the next marshaler

merge($marshalers)

Creates a marshaler that will apply $marshalers onto a value and then merges all of the results with array_merge. This expects the $marshalers to return arrays.

keys($fields, Access $acc = null)

Creates a marshaler that retuns the fields of the data

map($marshaler)

Creates a marshaler which takes a collection and returns an array of each of the marshaled items

collection($marshalers, Access $acc = null)

Creates a marshaler of a collection based off of the collection of marshalers passed in. Each $marshaler in $key => $marshaler will marshal each $value in $key => $value based on the $key.

on($marshalers, Access $acc = null)

Similar to collection, it marshals the fields of the collection based off of the map of marshalers passed in. The only difference is that it updates the fields in the original collection and returns the entire modified collection.

stringyKeys($cb)

Maps a key by allowing a stringy instance passed to callback for key manipulation

underscoredKeys()

Converts the keys to underscore style keys using the Stringy::underscored function

camelizeKeys()

Converts the keys to camelCase style keys using the Stringy::camelize function

identity()

Creates a marshaler for the identity function

mock($val)

Creates a marshaler that returns $val always. This is useful for testing

notnull($marshaler)

Creates a marshaler that will not allow null values to be passed to the marshaler. if a null value is passed, it just returns null and doesn't call the marshaler

hydrator()

Returns a statically cached instance of a default hydrator instance.

classNameHydrator($hydrator)

Treats the $class parameter as a class name and will instantiate a class and delgate to the internal hydrator

publicPropertyHydrator()

Assigns the properties from array into the $class object passed in via publicly accessible properties.

fromXML()

Parses XML string into an array.

class ArrayKeyAccess

Performs access on arrays via the key.

class ObjectPropertyAccess

Performs access on object properties via the property name

class AnyAccess

Delegates access to either ArrayKeyAccess or ObjectPropertyAccess if the data is an array or not.

This is the default accessor used.

access()

Returns a statically cached instance of AnyAccess


All versions of marshal with dependencies

PHP Build Version
Package Version
Requires danielstjules/stringy Version ^2.3
php Version ^5.6 || ^7.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 krak/marshal contains the following files

Loading the files please wait ....