Download the PHP package blueink/snorlax without Composer

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

Snorlax

Note: this repo is a fork from a snapshot of the github repo ezdeliveryco/snorlax, which no longer exists. Unfortunately, the previous git history / commits were lost.


A light-weight RESTful client built on top of Guzzle that gives you full control of your API's resources. Its based on method definitions and parameters for your URLs. See the usage below.

Installation

Install with Composer

Add the following requirement in your composer.json

Install:

Basic Usage

As you can see, each action on your resource is defined an array with two keys, method, defining the HTTP method for the request and path, which defines the path from the base URI returned by the getBaseUri method. You can mock URLs using environment variables as you wish.

Snorlax assume your API returns JSON, so it already returns an StdClass object with the response, decoded by json_decode. If you want to get the raw object returned by Guzzle, use $client->resource->getLastResponse().

Amending the response

As noted above, Snorlax returns an StdClass object, however Resources may overwrite the ->parse() method to manipulate the returned response. This is useful when an API returns a nested set of data such as {'pokemon': {'name':'Mew'}} and you only want the actual data (in this case pokemon). In this example we could use

This would return the actual pokemon object. Another scario is that you may want to return a Laravel Collection (Illuminate\Support\Collection) of objects, you could simply do

The $method argument is the name of the method which was called to perform the request, such as 'all', or 'get'. This is useful to manipulate different response, such as

Another usage could be to cast certain fields are data types. In this example, we'll cast any fields called created_at or updated_at to Carbon isntances

Sending parameters and headers

As said before, Snorlax is built on top of Guzzle, so it works basically the same way on passing headers, query strings and request bodies.

Changing client options

If you want to set default headers for every request you send to the default guzzle client, just use the headers options on your params config key, just like the Guzzle docs.

Setting a base URI

If all your resources are under the same base URI, you can pass it on the constructor instead of declaring on the resource class.

Using a custom client

If you don't want to use Guzzle's default client (or want to mock one), Snorlax accepts any class that implements GuzzleHttp\ClientInterface, so just pass your custom client in the constructor. Can be an instance or a callable.

Using a custom cache strategy & driver

If you don't want to use the VolatileRuntime cache driver or even want to change cache strategy, Snorlax allow you to inject any of the stragies and storages provided by kevinrob/guzzle-cache-middleware.

Using parallel requests

The parallel pool is made on the top of Guzzle, because of that, you should be using Guzzle.

The result of $requests is a StdClass with postsByUserOne and postsByUserTwo as properties.

Reconnections

Is possible to reconnect when Guzzle throws a GuzzleHttp\Exception\ConnectException. By default, Snorlax tries to reconnect 3 times.

If you want, you can change the number of tries with the retries parameter.

Contributing

Please see the CONTRIBUTING.md file for guidelines.

License

Please see the LICENSE file for License.


All versions of snorlax with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
guzzlehttp/guzzle Version ~6.1
monolog/monolog Version ^1.21
kevinrob/guzzle-cache-middleware Version ^1.0
rtheunissen/guzzle-log-middleware 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 blueink/snorlax contains the following files

Loading the files please wait ....