Download the PHP package antonioprimera/laravel-api-client without Composer

On this page you can find all versions of the php package antonioprimera/laravel-api-client. 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 laravel-api-client

Laravel Api Client

Installation

Install the pacakage via composer

composer require antonioprimera/laravel-api-client

If you want to use pre-configured clients and endpoints, rather than define authentication types, credentials, request methods and urls as part of your php code, you can create a new config file, named apiEndpoints.php.

Usage

The ApiClient can be used either based on a config file or by just creating and specifying all necessary authentication details in the code.

Example Usage without config

Create a Laravel Sanctum client. The Laravel Sanctum client will send its authentication token in the Authorization header, as the Bearer token.

Create a http client with basic authentication. This type of authentication requires the credentials to be set as an array with the username and password keys. These credentials will be encoded and sent in the Authorization header.

Create a http client with query authentication. For this type of authentication, the credentials are sent via query parameters in the url for get request or via the request body, for other request methods. You can provide any set of authentication data (not necessary username and password, like in the basic http authentication protocol).

The example below will make a get request to: http://my-api-endpoint-url.com?user=my-user-name&pass=my-pass&tk=my-token&id=15

Example Usage with config (see sample config below)

Create a laravel sanctum client based on the configured client 'mySanctumClient' and call a configured endpoint. If the api token is provided in the config, you can just call a configured endpoint or some other url. If the token is not available in the config, you must use the withCredentials(...) or setCredentials() method, before calling any endpoint / url.

Create a http client with basic authentication. If the credentials are provided in the config, you can just call a configured endpoint or some other url. If the credentials are not available in the config, you must use the withCredentials(...) method or the setCredentials(), before calling the endpoint.

Create a http client with query authentication. For this type of authentication, the credentials are sent via query parameters in the url for get request or via the request body, for other request methods.

You can use a configured client to make calls to endpoints with a given url, so it's not mandatory to configure all endpoints. Just call the 'get' / 'post' / 'put' / 'patch' / 'delete' / 'head' method on the client and provide the necessary data.

Config

By default, the config file apiEndpoints.php is used, so don't forget to create it if you want to use the api client based on config data.

If you want to use another config file, or to change the behavior of the ApiClient class, you must create your own ApiClient class in your project, inheriting the AntonioPrimera\ApiClient\ApiClient. Then you can override the static variable $config to point to your desider config file

The Api client can be used also without a config, by specifying the http client type, the authentication type, the credentials, the url and the method to be used to make the request.


All versions of laravel-api-client with dependencies

PHP Build Version
Package Version
Requires spatie/laravel-package-tools Version ^1.9
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 antonioprimera/laravel-api-client contains the following files

Loading the files please wait ....