Download the PHP package floor9design/search-string-parser without Composer
On this page you can find all versions of the php package floor9design/search-string-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download floor9design/search-string-parser
More information about floor9design/search-string-parser
Files in floor9design/search-string-parser
Package search-string-parser
Short Description A php based parser class for usage in search logic
License GNU GENERAL
Homepage https://github.com/elb98rm/:search-string-parser
Informations about the package search-string-parser
search-string-parser
A php based parser that will turn a string into an array of search terms for usage in search logic. This software is currently in a beta release: 0.9.3
It is to be released on packagist.org.
Items left to look at:
- Finish ParserEn implementation - currently under development
- Testing has been restored to 100% on files not being redeveloped
- Documentation to be expanded to be more "ELI5"
This should be PSR-2, PSR-4 compliant, but as it's a beta there may be some problems.
Install
Via Composer
Usage
There are different engines Parsers available. You can easily choose which you want to use. Currently in this Beta version ParserSimple and ParserEn are included.
Instantiate the wrapper using an object of the type of search you want:
This will give you the following results set:
Spaces are treated as "OR", with literals meaning "This string exactly"
- hello world => hello OR world
- "hello world" => hello AND [ space ] AND world
Your search string can include a combination of the following items:
- strings - eg: hello world
- literal string - eg: "hello world"
- int - eg: 1
- float - eg: -14.54
- array
- multi-dimensional array
These are all parsed internally to form an array ready for you to use as you see fit!
Here is a more complex example:
This gives the following result:
You can also change the delimiter:
This will give you the following results set:
A practical use case; In Zend Framework you may need to set up a set of search terms:
Obviously, this is just a push in the right direction, though similar things can be done in almost all frameworks (as well as in raw SQL).
Testing
Ensure that you have run composer scripts to generate vendor/autoload.php Run the following in command line at the project root:
Credits
License
GNU GENERAL PUBLIC LICENSE. Please see License File for more information.