Download the PHP package sdpmlab/anser-action without Composer
On this page you can find all versions of the php package sdpmlab/anser-action. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sdpmlab/anser-action
More information about sdpmlab/anser-action
Files in sdpmlab/anser-action
Package anser-action
Short Description PHP simple API connection library.
License MIT
Informations about the package anser-action
Anser-Action:A simple API connection library for PHP
Anser-Action is a library based on Guzzle7
, it provides you the ability to handle HTTP responses and exceptions like using the callback
design pattern of jQuery Ajax
.
Besides, Anser-Action is also able to achieve parallel connection swiftly, enables you to handle multiple HTTP connections and responses in a short time.
Installation
Requirements
- PHP 7.2.5↑
- Composer
- Requirements for installing Guzzle7
Composer installation
Use Composer to download the needed dependencies and libraries under your project root directory.
Quick Start
Single HTTP Connection
Through the Action
object provided by Anser, you can define your HTTP connection straightforwardly.
By setting up the doneHandler
, you can design the execution logic when the connection succeeded, and then store the needed data inside Action
object by means of setMeaningData
.
Action
must call the do()
method to execute connection, subsequently, you can take out the processed data through getMeaningData()
.
Error handling
You can set up failHandler
callback function to define the processing logic when encountering HTTP connection errors, server errors, or the client errors.
Concurrent Connection
You can directly use the ConcurrentAction
class provided by the library.
By passing multiple Action
entities, you will be able to achieve parallel connection fastly, and get the processed results uniformly.
Centralized Connection Management
Inherit \SDPMlab\Anser\Service\SimpleService
class to manage and make similar connections abstract.
These connections will be able to share basic configurations with each other, and through this design pattern, you can reduce code replication maximally and enhance maintainability as well.