2017 © Pedro Peláez
 

library search-dev

RollerworksSearch monolith development (use separate packages instead)

image

rollerworks/search-dev

RollerworksSearch monolith development (use separate packages instead)

  • Tuesday, July 24, 2018
  • by sstok
  • Repository
  • 5 Watchers
  • 56 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 10 Open issues
  • 36 Versions
  • 0 % Grown

The README.md

RollerworksSearch

About RollerworksSearch

RollerworksSearch is a powerful search-system for PHP. Created to make searching in a PHP powered application as simple and fast as possible., (*1)

Whether you want to search for users in your SQL database, want to provide a powerful search system for searching products using an ElasticSearch back-end or are looking for a way to abstract filtering for a reporter., (*2)

##### :warning: RollerworksSearch v2.0 is not stable yet, backward compatible changes should be expected. ##### If you are looking for a stable version, please wait for a final v2.0 release., (*3)

How about complex data structures?

A complex data is structure is no problem, say your customer data is stored in the "customer" table, the "invoices" data is stored in it's own table, and the details of the invoices have there own table., (*4)

Instead of writing a very verbose SQL query, your users can use the easy to learn StringQuery syntax:, (*5)

invoice-price: > $20.00; invoice-row-label: ~*"my cool product"; customer-type: !consumer., (*6)

You just searched in three relational tables using a single condition with a user-friendly syntax. And that is just the start, RollerworksSearch can work with any locale, custom input format, or storage system., (*7)

Search conditions can be as simple or complex as you need them to be. Including grouping and nesting for the best possible result., (*8)

Features

RollerworksSearch provides you with most of the features you would expect from a search system, including:, (*9)

  • Localized input processing using the StringQuery format;
  • User-friendly format validation;
  • Integration with API-Platform;
  • Integration for Symfony 4.4 and up (Symfony Flex supported).

And support for the most poplar storage systems., (*10)

Installation and usage

Please ignore the instructions below if your use a framework integration., (*11)

[Read the Documentation][4] for complete instructions and information., (*12)

Install the RollerworksSearch "core" library using Composer:, (*13)

$ composer install rollerworks/search

And create the SearchFactory to get started., (*14)

use Rollerworks\Component\Search\Searches;
use Rollerworks\Component\Search\Exception\InvalidSearchConditionException;
use Rollerworks\Component\Search\Extension\Core\Type\TextType;
use Rollerworks\Component\Search\Extension\Core\Type\IntegerType;
use Rollerworks\Component\Search\Extension\Core\Type\ChoiceType;
use Rollerworks\Component\Search\Input\ErrorPathHumanizer;
use Rollerworks\Component\Search\Input\StringQueryInput;
use Rollerworks\Component\Search\Input\ProcessorConfig;

// The factory is reusable, you create it only once.
$searchFactory = Searches::createSearchFactory();

// Create a fieldset to inform the system about your configuration.
// Usually you will have a FieldSet for each data structure (users, invoices, etc).
$userFieldSet = $searchFactory->createFieldSetBuilder()
    ->add('firstName', TextType::class)
    ->add('lastName', TextType::class)
    ->add('age', IntegerType::class)
    ->add('type', ChoiceType::class, [
        'choices' => ['Consumer' => 'c', 'Business' => 'b'],
    ])
    ->getFieldSet('users');

// Now lets process a string query.
// Tip: the input processor is reusable.
$inputProcessor = new StringQueryInput();

try {
    // The ProcessorConfig allows to limit the amount of values, groups
    // and maximum nesting level. The defaults should be restrictive enough
    // for most situations.
    $processorConfig = new ProcessorConfig($userFieldSet);

    // The `process` method processes the input and produces 
    // a valid SearchCondition (or throws an exception when something is wrong).
    $condition = $inputProcessor->process('firstName: sebastiaan, melany;');
} catch (InvalidSearchConditionException $e) {
    // Each error message can be transformed to a localized version
    // using the Symfony Translator contract.

    $translator = ...; // \Symfony\Contracts\Translation\TranslatorInterface

    // Note: The ErrorPathHumanizer only works for the `StringQueryInput` input processor.
    $errorPathHumanizer = new ErrorPathHumanizer($translator);

    foreach ($e->getErrors() as $error) {
       echo '<span>' $errorPathHumanizer->humanize($error->path) .  ' </span><span>' . htmlentities($error->trans($translator), ENT_COMPAT | ENT_IGNORE, 'UTF-8') '</span>' . PHP_EOL;
    }
}

That's it! The $condition contains the SearchCondition in a normalized data format which can be used in a condition processor (like ElasticSearch), or be exported into another format like JSON for easier usage in a URL., (*15)

Note: RollerworksSearch is composed of multiple separate packages (to keep the architecture slim), the "core" package provides everything you need to get started., (*16)

Searching a (document) storage requires the installation of additional packages., (*17)

What about validation?

Each field type ensures the value is transformed to the correct format, either a date input is automatically transformed to a DateTimeImuttable object., (*18)

A field that expects an integer will fail when the provided input is not an integer., (*19)

To enforce more strict constraints like a maximum amount for an integer field you can use the Symfony Validator extension., (*20)

Resources

Who is behind RollerworksSearch?

RollerworksSearch is brought to you by Sebastiaan Stok., (*21)

License

RollerworksSearch is released under the MIT license., (*22)

The types and extensions are largely inspired on the Symfony Form Component, and contain a big amount of code from the Symfony project., (*23)

Support

Use the issue tracker to create a new support question., (*24)

Note: Please be patient, it might take some time before your question is answered. Do not ping the maintainers., (*25)

Contributing

This is an open source project. If you'd like to contribute, please read the Contributing Guidelines. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section., (*26)

Note: RollerworksSearch is developed in a monolith repository, do not open pull request against repositories marked as [READ-ONLY], thank you., (*27)

The Versions

24/07 2018

v2.0.0-ALPHA14

2.0.0.0-alpha14

Doctrine DBAL extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

search doctrine dbal rollerworks

13/11 2017

v0.1.0

0.1.0.0

ElasticSearch (Elastica) extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

search doctrine dbal rollerworks

25/08 2017

v2.0.0-ALPHA5

2.0.0.0-alpha5 https://rollerworks.github.io/

RollerworksSearch provides you with a powerful search system

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

filter search rollerworks

16/08 2017

v2.0.0-ALPHA4

2.0.0.0-alpha4 https://rollerworks.github.io/

RollerworksSearch provides you with a powerful search system

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

filter search rollerworks

06/08 2017

v2.0.0-ALPHA3

2.0.0.0-alpha3 https://rollerworks.github.io/

RollerworksSearch provides you with a powerful search system

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

filter search rollerworks

26/01 2017
10/01 2017

v1.1.1

1.1.1.0

Doctrine DBAL extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

search doctrine dbal rollerworks

13/03 2016
03/12 2015
16/09 2015

v1.0.0

1.0.0.0 https://rollerworks.github.io/

RollerworksSearch provides you with a powerful search system

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

filter search rollerworks

10/08 2015

v1.0.0-beta8

1.0.0.0-beta8

Doctrine DBAL extension for RollerworksSearch

  Sources   Download

MIT

The Requires

 

by Sebastiaan Stok

search doctrine dbal rollerworks