Download the PHP package icanboogie/facets without Composer

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

Facets

Release Build Status Code Quality Code Coverage Packagist

Together with the icanboogie/activerecord package, this library makes it easy to implement faceted search. The library makes it especially easy to parse query strings (bag of words), use serialized criterion values such as sets (e.g. "1|2|3") or intervals (.e.g. "1990..2010"), and fetch records matching an array of conditions.

Fetching records matching conditions

A BasicFetcher instance can be used to fetch records matching a set of conditions. The fetcher takes care of the various steps required to build the query and fetch the matching records. These steps can be summarized as follows:

  1. Parse the specified modifiers and extract conditions, offset, limit, order and query string.
  2. Build the initial query.
  3. Invoke criteria to alter the query.
  4. Alter the query with the conditions.
  5. Count the total number of records that match the query.
  6. Alter the query with the order.
  7. Alter the query with the offset and limit.
  8. Fetch the records matching the query.
  9. Invoke criteria to alter the records.
  10. Return a RecordCollection instance containing the records.

The following example demonstrates how a BasicFetcher instance can be used to fetch online articles that are classified in the "music" category, and were published between 2010 and 2014. A maximum of 10 articles can be fetched, and they are ordered starting with the most recent:

Fetch records using a model

The package adds the fetch_records() and fetch_record() methods to Model instances, which allow for records to be fetched directly from the model, without requiring a BasicFetcher instance to be built.

Note that the BasicFetcher instance created to fetch the records can be obtained using the second argument of the methods.

Properties of interest

Once the records have been returned the following properties might be of interest:

Altering the fetched records

Fetched records are returned as a RecordCollection instance, such an instance can be used to fire the alter event of class RecordCollection\AlterEvent. Event hooks may use this event to alter the records of the collection, for instance fetching the images associated with a collection of articles using a single query.

Fetching records using a CriterionList instance

If using a BasicFetcher instance is not enough of a challenge for you, you can use a CriterionList instead and do all the hard work yourself:

Criterion values

Criterion values are usually created when a CriterionList instance alters a query with values. If a value's key matches a criterion identifier, the parse_value() of that criterion is invoked to retrieve a criterion value, which might be the exact same value, or a CriterionValue instance if the value is complex, for instance an interval or a set.

The resulting criterion value is used to alter the query during alter_query_with_value(). Interval values result in BETWEEN ? AND ?, => ?, and <= ? conditions; while set values result in IN(?) conditions.

Interval values

Interval values are represented by IntervalCriterionValue instances. When specified as a string two dots .. are used to separate the lower and the upper bound. An interval value can be created with any of the following statements:

IntervalCriterionValue instances can also be used as strings:

IntervalCriterionValue instances can be used by criteria to create BETWEEN ? AND ?, >= ?, and <= ? conditions while they alter the query.

Set values

Set values are represented by SetCriterionValue instances. When specified as a string the pipe character "|" is used to separate the values. A set value can be created with any of the following statements:

SetCriterionValue instances can also be used as strings:

SetCriterionValue instances can be used by criteria to create IN(?) conditions while they alter the query.

Associating criteria with models

Criteria are associated with models using activerecord config fragments and the facets key. The criteria for a model are specified using the model's identifier. The activerecord_facets config is synthesized from fragments. The criteria and criterion_list getters are added to the Model class by the package and are used to respectively retrieve the config criteria and the CriterionList instance associated with a model.

Note: This feature currently requires the ICanBoogie framework and the icanboogie/bind-facets package. A similar feature can be implemented using only the icanboogie/prototype package. In which case, you only need to define the criteria and criterion_list getters for the Model class.

The following example demonstrates how the nid and slug criteria are associated with the nodes model, and how the month and year criteria are associated with the articles model:

Note that criteria are inherited. In our example, because articles extends nodes it inherits its nid and slug criteria.

Obtaining the criteria associated with a model

The criteria array can be retrieved from a model using the criteria getter that is added by the package. The getter returns the criteria and inherited criteria as they are defined in the activerecord_facets config.

The criteria and criterion_list getters are added to the Model class

Obtaining the CriterionList instance associated with a model

The CriterionList instance associated with a model can be retrieved from a model using the criterion_list getter that is added by the package. The getter returns a CriterionList instance created from the criteria obtained through the criteria getter.


Requirements

The package requires PHP 5.5 or later.

Installation

Documentation

The package is documented as part of the ICanBoogie framework documentation. You can generate the documentation for the package and its dependencies with the make doc command. The documentation is generated in the build/docs directory. ApiGen is required. The directory can later be cleaned with the make clean command.

Testing

Run make test-container to create and log into the test container, then run make test to run the test suite. Alternatively, run make test-coverage to run the test suite with test coverage. Open build/coverage/index.html to see the breakdown of the code coverage.

License

icanboogie/facets is released under the New BSD License.


All versions of facets with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
icanboogie/activerecord Version ^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 icanboogie/facets contains the following files

Loading the files please wait ....