Download the PHP package itvisionsy/php-es-orm without Composer

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

ElasticSearch PHP ORM and Query Builder (es-mapper)

This is a simple ORM mapper for ElasticSearch for PHP.

ElasticSearch DSL query builder for PHP.

Collaborators required

If you can join me in updating and maintaining this project, please send a message to [email protected]

Requirements

Installation

Composer

Manual download

Head to the latest version here then download using one download button.

How to use?

For the Query Builder, read this README instead

That is simple:

Per index query:

  1. Create a class extending the main query class (for general index use) .
  2. Fill in the abstract methods. They are self-descriptive.
  3. Use the created class ::find($type, $id), ::query($type, array $query =[]), and ::all($type) You will get a list of Model objects where you can object-property access to get all the info. i.e. $model->name to get the name property, ...

Per type query

  1. Create a class extending the type query class. OR create a class extending the main query class and implementing the TypeQueryInterface interface and use the TypeQueryTrait trait
  2. Fill in the abstract methods. They are self-descriptive.
  3. Use the methods: ::find($id), ::all(), and ::query(array $query=[]). You will get a list of Model objects the same way described above.

Please note

Methods' parameters are mapped to original elasticsearch methods and parameters as follows:

Querying for data

The query class is just a simple interface allows you to send DSL queries, or perform other ElasticSearch requests. The ::query() method for example will expect to receive an assoc-array with a well-formed DSL query.

However, you can use the query builder to builder the query and get a well-formed DSL array out of it.

You can use a type-query query builder to build the query and execute it directly:

Or you can use a generic query builder to build the query then you can modify it using other tools:

Please refer to this file for more detailed information.

Retrieving results

The returned result set implements the ArrayAccess interface to access specific document inside the result. i.e.

You can then get a document like this:

Or you can use the dot notation like that:

Accessing document data

On the model object, you can access the results in many ways:

  1. using the object attribute accessor $object->attribute
    • if the attribute starts with underscore (_) then it will try to fetch it first from the meta information, then the attributes, and then from the internal object properties.
    • if the attribute starts with two underscores (__) then it will try to fetch first from the internal object properties, then attributes, then meta.
    • if not precedence underscores, then it will try to fetch from the attributes, then meta, then internal object properties.
  2. using the $object->getAttributes()[attribute], as the getAttributes() will return the document data as an array (first level only).
  3. using the $object->getAttributes($attribute1, $attribute2, ...) which will return a single (or array) value[s] depending on the requested attributes

Creating new documents

Either way will work:

  1. Use the index query static method

  2. Use the type query static method:

Updating a document

You can update an already indexed document by:

  1. Either Re-indexing a document with the same type and id, OR
  2. Or update(array $data, array $parameters=[]) method on the model's object:

Deleting a document

The same way you can update a document, you can delete it:

  1. Calling the static method ::delete($type, $id) on the index query
  2. Calling the method ->delete() on model's object.

Adding extra methods

You may need to add extra custom methods like top($numOfDocs) or anything else. To do so, you need to create the method name you wish as protected in the query sub-class. The name should be prefixed with _ (i.e. _top) then, you can either

Extending the Model class

You can extend the Model class easily. Just extend it! In case you were using the namespaces, you can set the models namespace in the query class by overriding the modelNamespace public method. This method should return a string ending with \ After that, you need to call the ->setModelClass($class) on the query result object.

Examples

Please check tests/ folder. Basically, the case1.php is the main file.

License

This code is published under MIT license.


All versions of php-es-orm with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
elasticsearch/elasticsearch 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 itvisionsy/php-es-orm contains the following files

Loading the files please wait ....