Download the PHP package corex/client without Composer
On this page you can find all versions of the php package corex/client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package client
CoRex Client
Various clients for php (Http, Rest, etc.)
Supported methods: get, post, put, delete, patch, options.
A typical flow would be ...
- Create and set properties on client.
- Create and set properties on request.
- Call client with request (properties on client and request are merged).
- Use response to get data (various methods exists to get data).
Please note that the client might throw exceptions.
Base client (abstract)
All clients extends base client which means there will be a common set of methods available.
- Url can be specified on constructor.
- baseUrl() - Specify base url (overwrite base url set through constructor).
- timeout() - Specify timeout in seconds.
- token() - Specify token. Tokens are used to specify {} in path i.e. a path could be "/user/{id}" and calling token('id', 4') will result in "/user/4".
- param() - Specify parameter. Example: param('param', 'test') will be added as [?/&]param=test on url. All parameters are url encoded.
- header() - Specify request header(). Example: header('Accept', 'application/json').
- userAgent() - Specify user agent.
- getDebug() - Get debug information (response not returned).
Normally, setting tokens, parameters and headers on request will override tokens, parameters and headers on client. However, it is possible to specify them as final on client.
Base request (abstract)
- path() - Specify path. Will be added to url.
- token() - Specify token (explained elsewhere). It will override client unless it is set as final.
- param() - Specify parameter (explained elsewhere). It will override client unless it is set as final.
- header() - Specify header (explained elsewhere). It will override client unless it is set as final.
Base response (abstract)
- header() - Get response header.
- headers() - Get response headers.
- body() - Get body.
- status() - Get status (http status). If request succeeded, it will return 200. Get messages through class Status.
Http\Client (extends base client)
Methods inherited from base client.
A few examples.
Http\Request (extends base request)
Methods inherited from base request + following...
- body() - Set body.
A few examples.
Http\Response (extends base response)
Methods inherited from base response.
A few examples.
Rest\Client (extends base client)
Methods inherited from base client.
A few examples.
Rest\Request (extends base request)
Methods inherited from base request + following...
- field() - Set field i.e. field('firstname', 'Roger');
A few examples.
Rest\Response (extends base response)
Methods inherited from base response + following...
- value() - Get value from response. Uses dot notation i.e. value('actor.firstname');
- toArray() - To array.
A few examples.
Rest\Entity (abstract) / Rest\Collection (abstract)
There exist a lot of methods to extract data from collection. Look at corex/support to see available methods on Collection. Added following method(s)...
- toArray() - To array.
An example of using Entity and Collection.