Download the PHP package budgetdumpster/hal-formatter without Composer

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

HalFormatter

Installation

composer require budgetdumpster/hal-formatter:dev-master

Tests

Tests can be run using the command phpunit in the library root directory

Usage

Configuration

If you don't have a resource that has embedded resources, the $embedded parameter in the HalFormatter::formatResource is optional. However, if you do want to incorporate embedded resources into your response, the configuration will help you build out the desired structure.

The library is based on the assumption that related resources, in most ORMs, end up in a property on the model when the relationship is retrieved. What the configuration allows you to do is move those related resources to the embedded section of the response based on the property.

So for example, you might have something like: Model::person_id - as the identifier for the related resource Model::person - the property the actual Person model is pulled into

and as a configuration you have:

What this configuration tells us is - we are going to take the data in the Model::person property and move it to the embedded resources under the $key key and any links for that resource will use the value of $uri. The library will work with individual models as well as arrays or collections of models.

Formatting a resource or collection

The most difficult part of this library is understanding the configuration (and since it's a matrix, you can tack on multiple configurations. Let's use the example configuration above and the assumption that our model will have a property on it called person

This will return an address collection, each entry in the address collection will have the person property removed and will have a person collection in the embedded resources.

In addition to the small API available, HalFormatter extends Nocarrier\Hal, so all the native functions of Nocarrier\Hal are available for use


All versions of hal-formatter with dependencies

PHP Build Version
Package Version
Requires nocarrier/hal Version ^0.9.12
php Version >=5.5.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 budgetdumpster/hal-formatter contains the following files

Loading the files please wait ....