Download the PHP package dcarbone/php-object-merge without Composer

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

php-object-merge

This is a simple library that facilitates the merging of two or more PHP stdClass object properties

Build Status

Non-Recursive

The fastest approach to merging two objects will simply apply the fields present in the list of ...$others to the root object.

Recursive

If you require recursive merging of child objects, that is also possible:

Callback

If you wish to sometimes manually handle the merging of two values, you may do so using the provided _callback functions.

Callback providing

You may provide any php-callable notation you wish, including:

Callback arguments

The callback function will be provided exactly one parameter, and it will always be an instance of ObjectMergeState.

Callback response

If the callback function returns anything other than an instance of ObjectMergeResult, it is used outright as the value of the merge, without further processing or recursion.

See comments on ObjectMergeResult for how each parameter is handled.

Merge Options

The object_merge and object_merge_recursive functions have sister functions named object_merge_opts and object_merge_recursive_opts respectively. Each of these has a required $opts argument that must be a bitwise inclusive or of your desired options.

OBJECT_MERGE_OPT_CONFLICT_OVERWRITE

This is the default option.

This means that when the provided root object already has a field seen in one of the ...$others, the value of the LAST of the $others objects will ultimately be used

Example:

OBJECT_MERGE_OPT_CONFLICT_EXCEPTION

When this is provided, an exception will be raised if there is a type mismatch

Example:

OBJECT_MERGE_OPT_UNIQUE_ARRAYS

NOTE: This only has an effect when doing a recursive merge!

When this is provided, any seen array value that does not have a type conflict with an existing field type has its value pass through array_values(array_unique($v)).

This has the net effect of returning a re-indexed array consisting of only unique values.

Example:

OBJECT_MERGE_OPT_COMPARE_ARRAYS

NOTE: This only has an effect during a recursive merge!

When this is provided, individual array offsets will have their values compared and merged, rather than merely appended together.

Example 1:

Example 2:

OBJECT_MERGE_OPT_NULL_AS_UNDEFINED

When specified, NULL values are treated as UNDEFINED, meaning they will not cause a type conflict to be risen and the non-null value will be used in the merge.

This can be useful if you do not want to have all type conflicts to be overwritten with the right-hand value, but want to ignore null to not null differences.

Example:


All versions of php-object-merge with dependencies

PHP Build Version
Package Version
Requires php Version >=5.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 dcarbone/php-object-merge contains the following files

Loading the files please wait ....