Download the PHP package mkcg/php-query-model without Composer

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

Presentation

Simple multi-database library to search content on different engines and aggregate those results into document-oriented structures.

The library define the class MKCG\Model\DBAL\QueryEngine to build documents using different Drivers.

It also defines a simple ETL to be able to easily and efficiently synchronize content between different datasources.

Engine API

The QueryEngine API define two methods : query() and scroll().

Each one can fetch and build documents using the provided \MKCG\Model\Model with the appropriate \MKCG\Model\DBAL\QueryCriteria. However, the scroll() method return a \Generator and internally performs multiple batches to efficiently scroll big collections.

Examples

Drivers definition

Each Driver is responsible to perform queries on a single datasource (database, HTTP API, local files, ...) and must :

Example

Runtime behaviors

Drivers

Type Name Description
Document-oriented database MongoDB Driver for MongoDB 3.6+
Relational database Doctrine Doctrine DBAL Adapter (MySQL, MariaDB are supported, other might not)
Search engine Elasticsearch Driver for Elasticsearch 5+ (Work in progress)
Search engine Redisearch Driver for redisearch
File reader CsvReader
HTTP Http Interact with remote url (Work in progress)
HTTP HttpRobot Parse robots.txt from remote url (Work in progress)
RSS RssReader Extract RSS from remote url
Sitemap SitemapReader Extract Sitemap urlset from remote url

Features supported by driver

Driver Scrollable Filterable Sortable Aggregatable Count
CsvReader YES YES NO YES YES
Doctrine YES YES YES YES YES
Http YES YES NO NO NO
HttpRobot YES NO NO NO NO
MongoDB YES YES YES YES YES
Redisearch YES YES YES YES YES
RssReader YES YES NO NO NO
SitemapReader YES YES NO NO NO
Algolia
Cassandra
Elasticsearch
PostgreSQL
ScyllaDB
Solr

Query criteria options

HTTP-based drivers :

Result-based filterable drivers :

Option Drivers Description
case_sensitive MongoDB, Result-based filterable drivers Perform case sensitive FILTER_FULLTEXT_MATCH search , default : false
filepath  CsvReader Absolute or relative filepath of the CSV
delimiter  CsvReader Field delimiter
json_formatter HTTP Format JSON response body using a callback
multiple_requests none , used by the QueryEngine Disable sub-requests batching when including sub-models
url HTTP-based drivers Define the URL to use to query
url_generator HTTP-based drivers Use a callback to generate the URL to use based on the Query
max_query_time HTTP-based drivers , MongoDB Max query time in milliseconds , default : 5000 (5 seconds)
allow_partial MongoDB , Elasticsearch Allow partial results to be returned , default : false
readPreference MongoDB https://docs.mongodb.com/manual/core/read-preference/index.html
readConcern MongoDB https://docs.mongodb.com/manual/reference/read-concern/index.html
batchSize MongoDB https://docs.mongodb.com/manual/reference/method/cursor.batchSize/index.html
diacriticSensitive MongoDB https://docs.mongodb.com/manual/reference/operator/query/text/index.html
name all Overrides the name defined into the SchemaInterface

When both url_generator and url are provided, then only url_generator is used.

Filters

Name Constant name  Description
IN FILTER_IN
NOT IN FILTER_NOT_IN
GT FILTER_GREATER_THAN
GTE FILTER_GREATER_THAN_EQUAL
LT FILTER_LESS_THAN
LTE FILTER_LESS_THAN_EQUAL
MATCH FILTER_FULLTEXT_MATCH Text search
CUSTOM FILTER_CUSTOM Allow to use a callable to apply complex filters

Constants are defined by the interface MKCG\Model\DBAL\FilterInterface

Filters supported by driver

Driver IN NOT IN GT GTE LT LTE MATCH CUSTOM
Http NO NO NO NO NO NO NO NO
HttpRobot NO NO NO NO NO NO NO NO
Doctrine YES YES YES YES YES YES Interpreted as LIKE "%value%" YES
Elasticsearch YES YES YES YES YES YES YES , using elasticsearch match filter WIP
MongoDB YES YES YES YES YES YES YES , using mongodb $text operator YES
Redisearch YES YES YES YES YES YES YES , using redisearch search syntax NO
CsvReader YES YES YES YES YES YES Interpreted as LIKE "%value%" YES
RssReader YES YES YES YES YES YES Interpreted as LIKE "%value%" YES
SitemapReader YES YES YES YES YES YES Interpreted as LIKE "%value%" YES

CUSTOM filter type

Custom filters can be applied by providing a callable to the QueryCriteria instance :

The first argument of the callable SHOULD always be the Query instance. Other arguments might change depending on the driver.

Some Driver apply filters on fetched results and expect a false return value when the filter does not match. Internaly they apply a array_filter on each fetched result before :

callable arguments by Driver

Driver First argument Second argument
Doctrine \MKCG\Model\DBAL\Query \Doctrine\DBAL\Query\QueryBuilder
CsvReader \MKCG\Model\DBAL\Query array representing a raw item
RssReader \MKCG\Model\DBAL\Query array representing a raw item
SitemapReader \MKCG\Model\DBAL\Query array representing a raw item
MongoDB \MKCG\Model\DBAL\Quert array representing the filters passed as first argument of \MongoDB\Collection::find()

ETL

A deadly simple ETL is defined as a single class \MKCG\Model\ETL. It can be used in combination with the QueryEngine scroll API to transform then push content to different loaders;

Example

Aggregations

NAME Description
TERMS Number of distinct elements by field , with the field filters considered by the aggregation
FACET Number of distinct elements by field , with the field filters excluded by the aggregation
AVERAGE Average value of a numeric field
MIN Min value of a field
MAX Max value of a field
QUANTILE Quantile value of a field

Aggregrations supported

Driver TERMS FACET  AVERAGE MIN MAX QUANTILE
CsvReader NO NO YES YES YES NO
Doctrine YES YES YES YES YES YES
MongoDB YES YES YES YES YES YES
Redisearch YES YES YES YES YES YES

Test and examples

No tests are provided although some will be made using Behat for the release of the version 1.0.0. However a fully functionnal example is provided in examples/ and build documents using different kinds of Drivers

From : ./examples

By default this will run only two functions (located in index.php)

The pipelineEtl use the Engine scroll API to iterates a list of Product stored in MongoDB and apply different transformationsbefore pushing content with three loaders using the ETL component.

The searchOrder use the Engine scroll API to :

You might want to uncomment the other search functions to execute HTTP queries and fetch :

Roadmap

Expected features

Work In progress

Feature Description
Elasticsearch Driver
Callable validation Validate callable arguments using Reflection and PHP tokens

Backlog

Feature Description
Async HTTP requests Perform non-blocking HTTP requests
Lazy requests Only perform requests when the content is manipulated
Cacheable requests Cache results and detect what to invalidate using surrogate keys
Content synchronizer Use streamed eventlog to synchronize content between each datasource
Error handling strategies Allow to apply different strategy in case of a failure : crash, retry, fallback...
Generate schema classes Generate Schema classes by analyzing each database schema
Content lifecycle Allow to create / update / delete content

Drivers "nice to have"

Database Drivers

Streaming

Storage

Infrastructure

Service

Social Network

Contribution

Feel free to open a merge request for any suggestion or to contribute to this project.


All versions of php-query-model with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2.0
psr/http-client 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 mkcg/php-query-model contains the following files

Loading the files please wait ....