Download the PHP package nuad/graph-objects without Composer

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

PHP assoc array to class properties

Graph objects is a php5 hydrator which maps associative arrays to class instances using metadata defined in their classes, useful when working with database result sets or formats that can be easily formatted to assoc arrays (such as json).

The library has no extra requirements (except phpunit for testing). It does not require custom annotation syntax or makes use of doc comments in order to limit reflection usage and to keep things as simple and light as possible.


Installation

Installing with composer:

Usage

All the project files are under the Nuad/Graph namespace. The main interface that all graph objects must implement is the Graphable interface and all the functionality is in the GraphAdapter trait.

The two main methods that the library uses are the create() and graph() methods. The first one will just output a clean instance of an object and the second one will provide the metadata to map the assoc array to the object. Though the GraphAdapter provides a version of the create() method (that uses reflection to create the instance) the method may be to have an object created with whatever default values.

So assuming there is a dto,entity etc class called Person which may work as a base class for a User object. A simple definition of the Person class would be:

Now to put the library in use the above class becomes:

Note: The create method can be ignored as we can use the traits create() method but this way we can create an instance without the use of Reflection.

Now to use the class to map a $data assoc array lets say from a JSON format:

Now the $person var should be a new Person instance with the data from the json file.

Syntax

The graph method must return an Entity object. The Entity's constructor requires an array of names which will identify the class. The Entity contains a list of properties (defined with the properties() method) which is an assoc array with keys the names of the properties of the main class and values the type of each property.

Types

The types of the properties are divided in three main categories

  • flat types (Integer,Double,Boolean,FlatArray)
  • objects (refers to another graph object. The constructor requires a clean instance of that object)
  • collection (refers to an array of graph objects. The constructor also requires a clean instance of that object)

Inheritance and more complex types

Using the example above we will define a User class which will extend the Person and contain a Location object which will contain a Point object.

The extra Location and Point classes:

Note: The Location contains an object named point which is of type Point and is defined as such in the graph() method. The Point graph defines expected arrays to both of its properties. In the expected attribute you may put variations of the property name which may be encountered in the data.

And now to define the User child class:

Note: The GraphAdapter trait must be defined again and in the graph() method we extend the graph() method of the parent class as seen above.

Features


All versions of graph-objects 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 nuad/graph-objects contains the following files

Loading the files please wait ....