Download the PHP package krzysztof-gzocha/searcher without Composer

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

Searcher Build Status Scrutinizer Code Quality Code Coverage Packagist SensioLabsInsight

What is that?

Searcher is a framework-agnostic search query builder. Search queries are written using criterias and can be run against MySQL, MongoDB, ElasticSearch, files or whatever else you like. Latest version is supporting only PHP 7. Now tested also with Humbug

See this presentation to understand better

Why?

Have you ever seen code responsible for searching for something based on many different criteria? It can become quite a mess! Imagine you have a form with 20 fields and all of them have some impact on searching conditions. It's not a great idea to pass a whole form to some service at let it parse everything in one place. Thanks to this library you can split the responsibility of building query criteria to several smaller classes. One class per filter. One CriteriaBuilder per Criteria. This way, inside CriteriaBuilder you care only about one Criteria, which makes it a lot more readable and maintanable. You can later use exactly the same Criteria for different searches, with different CriteriaBuilder and even different SearchingContext which can use even different databases. You can even use searcher to find files on your system thanks to FinderSearchingContext.

Full documentation

Full documentation can be found at http://searcher.rtfd.io/

Installation

You can install the library via composer by typing in terminal:

Integration

Integration with Symfony is done in SearcherBundle

Idea

Example

Let's say we want to search for people whose age is in some filtered range. In this example we will use Doctrine's QueryBuilder, so we will use QueryBuilderSearchingContext and will specify in our CriteriaBuidler that it should interact only with Doctrine\ORM\QueryBuilder, but remember that we do not have to use only Doctrine.

1. Criteria

First of all we would need to create AgeRangeCriteria - the class that will holds values of minimal and maximal age. There are already implemented default Criteria in here.

2. CriteriaBuilder

In second step we would like to specify conditions that should be imposed for this model. That's why we would need to create AgeRangeCriteriaBuilder

3. Collections

In next steps we would need to create collections for both: Criteria and CriteriaBuidler.

4. SearchingContext

Now we would like to create our SearchingContext and populate it with QueryBuilder taken from Doctrine ORM.

If there is even small chance that your QueryBuilder will return null when you are expecting traversable object or array then you can use WrappedResultsSearcher instead of normal Searcher class. It will act exactly the same as Searcher, but it will return ResultCollection, which will work only with array or \Traversable and if result will be just null your code will still work. Here is how it will looks like:

Order

In order to sort your results you can make use of already implemented Criteria. You don't need to implement it from scratch. Keep in mind that you still need to implement your CriteriaBuilder for it (this feature is still under development). Let's say you want to order your results and you need value p.id in your CriteriaBuidler to do it, but you would like to show it as pid to end-user. Nothing simpler! This is how you can create OrderByCriteria:

Of course you don't need to use MappedOrderByAdapter - you can use just OrderByCriteria, but then user will know exactly what fields are beeing used to sort.

Pagination

Criteria for pagination is also implemented and you don't need to do it, but keep in mind that you still need to implement CriteriaBuilder that will make use of it and do actual pagination (this feature is under development). Let's say you want to allow your end-user to change pages, but not number of items per page. You can use this example code:

Of course if you want to allow user to change number of items per page also you can skip the ImmutablePaginationAdapter and use just PaginationCriteria.

Contributing

All ideas and pull requests are welcomed and appreciated :) If you have any problem with usage don't hesitate to create an issue, we can figure your problem out together.

Development

Command to run test: composer test.
All unit tests are tested with padric/humbug library for mutation testing, aiming to keep Mutation Score Indicator equal or close to 100%.

To run mutation tests you need to install humbug and run: humbug in main directory. Output should be stored in humbuglog.txt.

Thanks to

In alphabetical order

License

License: MIT
Author: Krzysztof Gzocha


All versions of searcher with dependencies

PHP Build Version
Package Version
No informations.
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 krzysztof-gzocha/searcher contains the following files

Loading the files please wait ....