Download the PHP package kapersoft/npmsearch-api without Composer
On this page you can find all versions of the php package kapersoft/npmsearch-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kapersoft/npmsearch-api
More information about kapersoft/npmsearch-api
Files in kapersoft/npmsearch-api
Package npmsearch-api
Short Description Search for NPM packages using npmsearch.com API
License MIT
Homepage https://github.com/kapersoft/npmsearch-api
Informations about the package npmsearch-api
Search for NPM packages using npmsearch.com API
This is an implementation of npmsearch.com API for the PHP programming environment. More information about npmsearch.com and their API can be found at their GitHub repository.
Installation
You can install the package via composer:
Usage
First you initiate the NpmSearch object.
If you like to use your own NpmSearch imeplementation. You can override the URL of the API in the constructor of Kapersoft\NpmSearch\NpmSearch
. You can also pass your your own Guzzle HTTP client to the constructor.
Search packages
You can search packages using the search
-method:
The result is converted to an array that looks like this:
Specify fields
By default the result will include all fields except readme
. You can specify the fields in the $fields
property of the NpmSearch
-object.
For example:
Will return this result:
Paging
By default the first 10 results will be returned. If you want to query more packages, you can specify the $start
and $rows
parameters:
Extended search methods
There are also extended search methods next the default search
-method mentioned above. You can search for example for packages by author:
Of course the $start
and $rows
parameters are also available for these methods:
Advanced search options
In the backend npmsearch.com is a proxy to an ElasticSearch server. So you can use ElasticSearch query string syntax in the search
method:
Available search methods
Below the complete list of all search methods:
search($q, $start = 0, $rows = 10)
searchByAuthor($author, $start = 0, $rows = 10)
searchByCreated($created, $start = 0, $rows = 10)
searchByDependencies($dependencies, $start = 0, $rows = 10)
searchByDescription($Description, $start = 0, $rows = 10)
searchByDevDependencies($devDependencies, $start = 0, $rows = 10)
searchByHomepage($homepage, $start = 0, $rows = 10)
searchByKeywords($keywords, $start = 0, $rows = 10)
searchByMaintainers($maintainers, $start = 0, $rows = 10)
searchByModified($modified, $start = 0, $rows = 10)
searchByName($name, $start = 0, $rows = 10)
searchByRating($rating, $start = 0, $rows = 10)
- computed rating as per bin/ratings.jssearchByReadme($readme, $start = 0, $rows = 10)
searchByRepository($repository, $start = 0, $rows = 10)
searchByScripts($scripts, $start = 0, $rows = 10)
searchByTimes($times, $start = 0, $rows = 10)
searchByVersion($version, $start = 0, $rows = 10)
Testing
In the /tests
-folder is one test defined:
NpmSearchTest.php
tests theKapersoft\NpmSearch\NpmSearch-class
using mock Guzzle objects;
You can run the tests in your terminal:
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.