Download the PHP package dbstudios/doze without Composer

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

Installation

Basic Configuration

Doze only requires two things to function out of the box: a serializer, and a responder. For the serializer, Doze makes use of the symfony/serializer package. You can find more information on using it's features in their README, but a simple example can be found below.

In the example, we first create a new serializer instance. The first argument to the constructor is an array of normalizers, which the serializer uses to simplify data prior to serialization. Both DateTimeNormalizer and ObjectNormalizer are shipped with symfony/serializer, and are used to normalize DateTime and generic objects, respectively. The second argument is a list of supported encoder formats. Our example only supports JSON.

Next, we create a new Responder instance, and call it's createResponse() method to obtain our Response object, which contains things like the headers, HTTP status code, and the response body. Please see the symfony/httpfoundation package for more information on the Response object.

Field Selector Notation

Sometimes, a developer using your API may only want or need a few specific fields from an object or array. To that end, Doze implements a selector notation that can be used to limit which fields are serialized and returned.

When calling Responder::createResponse(), you can provide an "attributes" key, which tells the serializer which attributes should be serialized and returned. Using the "attributes" context key is documented in the serializer package, but Doze also supports an alternative method of building the attributes filter.

In the example below, $responder is the Responder instance we created in the previous example. Since the fields selector functionality is intended to be exposed to the end user of your API, we're retrieving the selector from the $_GET global variable.

Notice that the JSON output by $response->getContent() does not contain the field "someOtherField", which was not part of the selector.

Field selectors can also contain nested selectors. In the example below, assume that $data has a field named "nestedObject", which has the fields "name" and "property".

Serializing Database Objects

Objects loaded from the database by certain libraries (such as Doctrine cannot be cleanly serialized, since they automatically link to related objects. In some cases, serializing a database entity can result in a huge tree of child entities being serialized as well. This causes a lot of unnecessary data to be sent across the wire.

Doze provides a special normalizer, the EntityNormalizer, that is aware of such database entities (via the EntityInterface interface), and will serialize ONLY the entities ID unless it is explicitly requested using field selectors. To use it, any classes that are used by your DBAL must implement the EntityInterface, and the EntityNormalizer must be in your serializer's normalizer stack above any other normalizers that might accidentally try to serialize your objects (such as the ObjectNormalizer used in previous examples).

With the extra normalizer added, any objects that implement EntityInterface will have ONLY their ID serialized, instead of the entire object, and any child objects. This can be overwritten by using explicitly selecting the entity (and, optionally, and of it's fields) using the Field Selector Notation.

Paged Collections

Coming soon.


All versions of doze with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
symfony/http-foundation Version ^4.0
sensio/framework-extra-bundle Version ^5.0
symfony/serializer Version ^4.0
symfony/property-access Version ^4.0
dbstudios/doctrine-entities Version ^1.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 dbstudios/doze contains the following files

Loading the files please wait ....