Download the PHP package laragear/api-manager without Composer

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

Api Manager

Latest Version on Packagist Latest stable test run Codecov Coverage Maintainability Sonarcloud Status Laravel Octane Compatibility

Manage multiple REST servers to make requests in few lines and fluently. No more verbose HTTP Requests!

Become a sponsor

Your support allows me to keep this package free, up-to-date and maintainable. Alternatively, you can spread the word!

Requirements

Installation

Require this using Composer into your project:

Usage

Creating an API Server

To make use of an API server, define a class that extends Laragear\ApiManager\ApiServer. You may use the make:api Artisan command to make a ready-made stub in the app\Http\Apis directory.

You will receive a file with a base URL and actions, and space to add some headers and a bearer token. You're free to adjust it to your needs.

[!NOTE]

You can override the API Server stub creating one in stubs/api.stub.

Inline Actions

Setting actions in the API class solves the problem of having multiple endpoints and preparing each one every time across your application, which can led to errors or convoluted functions full of text.

The easiest way to define actions is to use the Laragear\ApiManager\Attributes\Action attribute on top of the class with the action name in camelCase (like it was a class method), and the URL path. You may also set the HTTP verb to use, otherwise get will be inferred.

For example, to see the latest chirp on the server, we could call latest directly from our ChirpApi.

Alternatively, you can call an action without arguments as it were a property, especially if just a GET method over the server.

When calling an action that requires parameters, the arguments will be passed down to the HTTP Request as part of the body.

If the route has named parameters, lile chirp/{id}, you can set them as arguments when invoking the server.

While you're at it, add the PHPDoc manually to your API Server to take advantage of autocompletion in your IDE (intellisense).

[!NOTE]

You can still use the old way of using the $actions array, but is being deprecated.

Method actions

For more complex scenarios, you may use a class method. Just be sure to type-hint the PendingRequest on any parameter if you need to customize the request.

Then later, you can invoke the class methods like any Monday morning.

[!NOTE]

Method actions take precedence over inline actions.

As with inline actions, method actions can be also executed as it where properties if these don't require arguments.

Authentication

An API Server supports the three kinds authentication of the HTTP Client in Laravel: Basic, Digest and Bearer Token. You may define each of them as an array of username and password using authBasic() or authDigest(), and authToken() with the token, respectively.

[!WARNING]

Don't use an associative array to match the underlying methods. Since Laravel doesn't warranty consistency on named arguments, you should opt for simple arrays or key => value.

Before & After building a request

You can modify the request before and after it's bootstrapped using the beforeBuild() and afterBuild() respectively. The beforeBuild() is executed after the PendingRequest instance receives the base URL, and the afterBuild() is called after the headers and authentication are incorporated.

You're free here to tap into the request instance and modify it for all endpoints, or return an entirely new PendingRequest instance.

Overriding a request

The API request can be overridden as usual. All methods are passed down to the Illuminate\Http\Client\PendingRequest instance if these don't exist on the API Class.

[!NOTE]

If the method exists in your API Class, it will take precedence.

Dependency Injection

All API Servers are resolved using the Service Container, so you can add any service you need to inject in your object through the constructor.

You can also create a callback to resolve your API Server in your AppServiceProvider if you need more deep customization to create it.

Concurrent Requests

To add an API Server Request to a pool, use the onPool() method for each concurrent request. There is no need to make all requests to the same API server, as you can mix and match different destinations.

You may also name the requests using a second argument to on().

Wrapping into custom responses

You may find yourself receiving a response and having to map the data to your own class manually for convenience. Instead of juggling your way to do that, you can automatically wrap the incoming response into a custom "API Response."

First, create a custom response for an api using make:api-response, the API you want to use, and name the custom response with the same name of the endpoint. Ideally, you would want to name it the same as the action or method you plan to use it for.

You will receive a file in App\Http\Apis\{ApiServer}\Responses like this:

[!NOTE]

You can override the API Response stub creating one in stubs/api-response.stub.

In this class you can make any method you want. Since your class will extend the base Laravel HTTP Client Response class, you will have access to all its convenient methods.

Once you finish up customizing your custom API Response, you may set the Laragear\ApiManager\Attributes\Response attribute with the response class name on top of your method.

[!NOTE]

You can still use the old $responses array to map custom Responses to your method, but is being deprecated.

This will enable the API Manager to wrap the response into your own every time you call that method to receive a response. For example, if you call view(), you will receive a new ViewResponse instance.

[!TIP]

When using async() requests, custom responses are automatically wrapped once resolved.

Testing

You can test if an API Server action works or not by using the fake() method of the HTTP facade.

Laravel Octane Compatibility

There should be no problems using this package with Laravel Octane.

Security

If you discover any security-related issues, please use the online form.

License

This specific package version is licensed under the terms of the MIT License, at the time of publishing.

Laravel is a Trademark of Taylor Otwell. Copyright © 2011–2026 Laravel LLC.


All versions of api-manager with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
guzzlehttp/guzzle Version ^7.10
illuminate/http Version 12.*|13.*
illuminate/config Version 12.*|13.*
illuminate/container Version 12.*|13.*
illuminate/support Version 12.*|13.*
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 laragear/api-manager contains the following files

Loading the files please wait ...