Download the PHP package nahid/apiz without Composer

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

APIZ

APIZ is a PHP API Client Development Kit, it helps you to manage HTTP API call in OOP way. You can easily handle and isolate all kinds of REST API calls and their responses by using this package.

Requirements

Installations

Configurations

There are no extra configurations for this package.

Usage

Lets see an example to consume API from https://reqres.in.

Suppose you need to create several API services for your project. Your service directory is app/Services. Now we are going to develop a service for https://reqres.in and make a class file ReqResApiService.php which will extend \Apiz\AbstractApi class.

getBaseURL() is an abstract method of the AbstractApi class. You need to override this method to set the proper base URL for your API.

Few APIs have a common prefix in their URL. Like, here reqres.in have a prefix api on every endpoint. So, we'll override the getPrefix() method to define the Prefix.

Now let's make a method to get all users info.

So, we are basically making a GET request to the URL https://reqres.in/api/users.

See, how easy it is to manage an API now?

Let's see another example.

Post Request with Form Params

Default Headers

Sometimes we need to bind some headers with all the requests. Suppose if you want to deal with the Github API, you have to send access_token in every request with the headers. So APIZ provide you a handy way to deal with this problem. Just override AbstractApi::getDefaultHeaders().

Cool, right?

You can easily use all HTTP verbs like get, post etc. It's totally hassle free. See more examples in the Examples Folder.

Query over Response Data

Sometimes we receive huge payload as a response from the APIs. It's quite daunting to parse proper data from that big payload.

No worries! We're using a powerful Query parser, named QArray by default to parse and query over the Response data.

Let's see how we can use this parser to parse the response we got for getAllUsers method from our previous example.

We're getting list of users in the data key in the response. From that we're collecting the first data. See, how easy it is!

You can find detail usage of the QArray here.

Additionally, there is a secret sauce for you.

If you don't want to query like: $users->query(), you can just do it like this: $users(). That means the response object is invokable and behave exactly like calling the query() method.

You're welcome. :D

Overriding HTTP Client

By default we are using Guzzle as our HTTP Client. But you are not bound to use this. You can easily use your own PSR7 supported HTTP Client with Apiz. Just pass an instance of your HTTP Client to our setClient() method. See an example here.

Here is our GuzzleClient to get an idea how your Client should look like:

List of methods for common HTTP verbs

List of Available methods

Contribution

Feel free send feedback and issues. Contributions to improve this package is most welcome too.


All versions of apiz with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0 | >=7.0
ext-json Version *
lib-libxml Version >=2.6.20
nahid/qarray Version ^2.0
guzzlehttp/guzzle Version ^6.0 | ^7.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 nahid/apiz contains the following files

Loading the files please wait ....