Download the PHP package macfja/redisearch-integration without Composer

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

PHP RediSearch Integration

MacFJA/redisearch-integration is a small library to ease usage of MacFJA/redisearch which is a RediSearch client.

Installation

Usage

You will mainly use ObjectManager (\MacFJA\RediSearch\Integration\ObjectManager) and ObjectRepository (\MacFJA\RediSearch\Integration\ObjectRepository).

This 2 interfaces are bundle into the ObjectWorker (\MacFJA\RediSearch\Integration\ObkectWorker) class, to ease usage. (If you are using a good Injection dependency, you will only need the interface)

Entity Mapping

There are 5 ways to map a PHP class to RediSearch object.

Annotation and Attribute Mapping

A class is considered as valid if it had at least one field mapping

Annotation PHP 8 Attribute Scope Default
@Index #[Index] Class Class name (with namespace)
@DocumentId #[DocumentId] Property or Method Randomly generate value
@TextField #[TextField] Property or Method None
@NumericField #[NumericField] Property or Method None
@TagField #[TagField] Property or Method None
@GeoField #[GeoField] Property or Method None
@Suggestion #[Suggestion] Property or Method None

Annotation and PHP 8 attribute mapping are parsed by respectively \MacFJA\RediSearch\Integration\Annotation\AnnotationProvider and \MacFJA\RediSearch\Integration\Attribute\AttributeProvider.

The Index mapping

The @Index(name, [prefix], [stopsWords]) (or #[Index(name, [prefix], [stopsWords])] for PHP 8 attribute) allow you to specify the index where the class will be put.

If the mapping is missing, the Full Class Qualifier Name (namespace + classname) will be used as index name, not prefix will be used and default StopsWorlds will be used.

The DocumentId mapping

The @DocumentId (or #[DocumentId] for PHP 8 attribute) allow you to specify which hash should be used to identify the document in Redis. The mapping can be set on a property, or on a method that can be call without any parameter.

If the mapping is missing, a random hash will be generated.

The TextField mapping

The @TextField([name], [noStem], [weight], [phonetic], [sortable], [noIndex], [unNormalized]) (or #[TextField([name], [noStem], [weight], [phonetic], [sortable], [noIndex], [unNormalized])] for PHP 8 attribute) allow you to add a text in the search engine. The mapping can be set on a property, or on a method that can be call without any parameter.

The NumericField mapping

The @NumericField([name], [sortable], [noIndex], [unNormalized]) (or #[NumericField([name], [sortable], [noIndex], [unNormalized])] for PHP 8 attribute) allow you to add a number in the search engine. The mapping can be set on a property, or on a method that can be call without any parameter.

The TagField mapping

The @TagField([name], [separator], [sortable], [noIndex], [unNormalized]) (or #[TagField([name], [separator], [sortable], [noIndex], [unNormalized])] for PHP 8 attribute) allow you to add a text in the search engine. The mapping can be set on a property, or on a method that can be call without any parameter.

The data link to TagField can be a scalar data, or a simple array (one dimension) of scalar

The GeoField mapping

The @GeoField([name], [noIndex], [sortable], [unNormalized]) (or #[GeoField([name], [noIndex], [sortable], [unNormalized])] for PHP 8 attribute) allow you to add a geographic (coordinate) in the search engine. The mapping can be set on a property, or on a method that can be call without any parameter.

The Suggestion mapping

The @Suggestion([group], [score], [increment], [payload]) (or #[GeoField([group], [score], [increment], [payload])] for PHP 8 attribute) allow you to add a geographic (coordinate) in the search engine. The mapping can be set on a property, or on a method that can be call without any parameter.

JSON Mapping

A JSON mapping file can contain several class mapping. The JSON should respect the Schema.

To enable JSON mapping you must use a \MacFJA\RediSearch\Integration\Json\JsonProvider. The JSON PHP extension must also be installed.

The JSON file must be given to the \MacFJA\RediSearch\Integration\Json\JsonProvider::addJson method.

(The JsonProvider can be added to a CompositeProvider)

XML Mapping

A XML mapping file can contain several class mapping. The JSON should respect the XSD Schema.

To enable XML mapping you must use a \MacFJA\RediSearch\Integration\Xml\XmlProvider. The SimpleXML PHP extension must also be installed.

The XML file must be given to the \MacFJA\RediSearch\Integration\Xml\XmlProvider::addXml method.

(The XmlProvider can be added to a CompositeProvider)

The interface mapping

You can create your own mapping by implementing the \MacFJA\RediSearch\Integration\Mapping interface, and add the class to the SimpleProvider.

(The SimpleProvider can be added to a CompositeProvider)

Events

The ObjectWorker emit several events to allow you to alter its behavior.

Event have separate into two main group: Before and After group. With the Before group you can change configurations before interacting with Redis. The After allow you to do more action with results.

The Before group

In bold parameters that can be changed.

Event name ObjectWorker method (Associated Interface) Available parameters
AddingDocumentToSearchEvent persist and persistSearch (ObjectManager) data, documentId, instance (r/o)
AddingSuggestionEvent persist and persistSuggestions (ObjectManager) suggestionMapping, instance (r/o)
CreatingIndexEvent createIndex (ObjectManager) builder, classname (r/o)
GettingSuggestionsEvent getSuggestions (ObjectRepository) classname (r/o), prefix, fuzzy, withScores, withPayloads, max, inGroup
GettingFacetsEvent getFacets (ObjectRepository) classname (r/o), query, fields
RemovingDocumentFromSearchEvent remove (ObjectManager) instance (r/o), documentId

The After group

In bold parameters that can be changed.

Event name ObjectWork method (Associated Interface) Available parameters
AddingDocumentToSearchEvent persist and persistSearch (ObjectManager) data (r/o), documentId (r/o), instance (r/o), update (r/o)
AddingSuggestionEvent persist and persistSuggestions (ObjectManager) group (r/o), suggestion (r/o), score (r/o), increment (r/o), payload (r/o), instance (r/o)
CreatingIndexEvent createIndex (ObjectManager) succeed (r/o), classname (r/o)
GettingAggregateEvent getAggregateCommand (ObjectRepository) aggregate, classname (r/o)
GettingFacetsEvent getFacets (ObjectRepository) classname (r/o), query (r/o), fields (r/o), facets
GettingSearchEvent getSearchCommand (ObjectRepository) search, classname (r/o)
GettingSuggestionsEvent getSuggestions (ObjectRepository) classname (r/o), prefix (r/o), fuzzy (r/o), withScores (r/o), withPayloads (r/o), max (r/o), inGroup (r/o), suggestions
RemovingDocumentFromSearchEvent remove (ObjectManager) instance (r/o), documentId (r/o), succeed (r/o)

Contributing

You can contribute to the library. To do so, you have Github issues to:

You also have PR to:

See CONTRIBUTING for more information.

License

The MIT License (MIT). Please see License File for more information.


All versions of redisearch-integration with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
macfja/redisearch Version ^2.0.0
psr/event-dispatcher 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 macfja/redisearch-integration contains the following files

Loading the files please wait ....