Download the PHP package ljmaskey/php-cmf-bindings without Composer

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

A PHP implementation for using the Compact Message Format

This is an attempt at implementing a PHP port for The Compact Message Format bindings project.

In creating this port, we referenced the Java and C# implementations the most, but the tests have been influenced by all the different implementations.

What is the Compact Message Format?

As noted in the README of the original project:

Bitcoin Classic introduced the Compact Message Format as a very simple but powerful format to encode and decode any type of messages.

The compact message format is a key/value-pair based format. Each key/value pair is called a token and a message is built up by a series of tokens.

Implementation Details

While the other implementations require a byte array to be given to the MessageBuilder and MessageParser, PHP does not have a concept of that. Instead, the classes in this package will accept either an array (specifically a list) or a stream resource.

For convenience, when using the addByteArray method on the MessageBuilder, this implementation will allow the items in the given array to either be byte values or individual ASCII characters (or a combination of these). When given an ASCII character, the package will convert that character to its corresponding byte value before adding it to the message.

Similarly, when the MessageParser is given an array for its data source (as opposed to a stream resource), that array can contain either byte values or individual ASCII characters. No matter the input, though, calling getByteArray on the parser will always return an array of byte values only.

Because PHP does not have support for method overloading, the MessageBuilder has explicitly named add... methods for each of the types that can be added. These should correspond with explicitly named get... methods defined on the MessageParser.

Unlike other implementations, there is no explicit close() method to be called.

When reading bytes from a stream, the position parameter is ignored. Instead, the package will always read the next byte (or bytes) from the stream.

Using the Package

To demonstrate usage of the package, we will use the same short example from the original project: a message with 3 tokens, each having a name and a value.

   Name=Paris
   Population=2229621
   Area=105.6

Message Creation

For creation of messages we use the builder pattern in the form of the MessageBuilder class.

The MessageBuilder class has a series of add...() methods each of which appends a token to your message. Each value that is added to a message requires a tag, with a tag being an integer between 0 and 65535 (inclusively).

Message Parsing

The MessageParser is using more of a SOX parser approach where you call MessageParser.Next() and then you can ask the parser for the tag and the actual value.

Exception Handling

\InvalidArgumentException

When there are problems with the data being passed into a method, the package will throw this exception. This could include being passed a non-list array when one is expected, or being passed a negative number when one is not allowed. Note, though, that this does not include errors with the underlying data being processed: those will throw either a SerializationException or an UnserializationException.

An \InvalidArgumentException indicates an issue that should be resolved by the calling code.

SerializationException, UnserializationException

These are thrown when the actual data being processed has errors. The resolution of one of these exceptions depends on the original source of the data.

InternalPackageException

These are thrown when something unexpected has happened with the package's own code.

These are exceptions that should be reported, as they need to be resolved by the package.


All versions of php-cmf-bindings with dependencies

PHP Build Version
Package Version
Requires php-64bit Version ^8.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 ljmaskey/php-cmf-bindings contains the following files

Loading the files please wait ....