Download the PHP package interfax/interfax without Composer
On this page you can find all versions of the php package interfax/interfax. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package interfax
InterFAX PHP Library
License
Send and receive faxes in PHP with the InterFAX REST API.
Installation
Two versions of this library exist, 1.x and 2.x. The 1.x version provides support for older versions of PHP, whilst the 2.x branch is designed to support the more recent releases of the language:
Package Version | Minimum PHP Version | Maximum PHP Version |
---|---|---|
1.x | 5.6 | 7.2 |
2.x | 7.3 | 8.1 |
Composer
The preferred method of installation is via Packagist and Composer. Run the following command to install the package and add it as a requirement to your project's composer.json
:
with 1.x version constraint
or with 2.x version constraint
Download the release
You can download the package in its entirety (from 1.0.2 onward). The Releases page lists all stable versions. Download any file
with the name interFAX-PHP-[RELEASE_NAME].zip
for a package including this library and its dependencies.
Uncompress the zip file you download, and include the autoloader in your project:
You may wish to rename the release folder to not include the RELEASE_NAME, so that you can drop in future versions without changing the include.
Build it yourself
The installation docs explain how to create a standalone installation.
Getting started
To send a fax for a pdf file:
Usage
Exceptions
Client
The client follows the 12-factor apps principle and can be either set directly or via environment variables.
Send a Fax
To send a fax, call the deliver method on the client with the appropriate array of parameters.
The method will take either a or argument. The is an array of file values.
Each entry can be:
- local path - if the file is larger than the allowed limit, it will be automatically uploaded as an
- uri (from an )
- an array defining a streamed resource (see below)
Sending a stream
Because of the high degree of flexibility that PHP stream resources offer, it's not practical to retrieve information automatically from a stream to send as a fax. As such, there are certain required parameters that must be provided:
Note that it is assumed that the stream will not exceed the file size limitation for an inline file to be sent. However, if a size parameter is provided for the stream, and this exceeds the limit, it will be automatically uploaded as a
Account
Balance
Determine the remaining faxing credits in your account.
More: documentation
Outbound
Resend fax
has an outbound property that can be accessed:
Get outbound fax list
Options: limit
, lastId
, sortOrder
, userId
Get completed fax list
Get outbound fax record
$client->outbound->find(fax_id)
Retrieves information regarding a previously-submitted fax, including its current status.
Get outbound fax image
$client->outbound->find(fax_id)->image()
The image is retrieved via a method on the outbound fax image object.
The fax image format is determined by the settings on the Interfax account being used, as detailed in the Documentation
Cancel an outbound fax
$client->outbound->find(fax_id)->cancel();
A fax is cancelled via a method on the Interfax\Outbound\Fax
model.
Search fax list
$client->outbound->search($options)
Search for outbound faxes with a hash array of options keyed by the accepted search parameters for the outbound search API endpoint.
Options: ids
, reference
, dateFrom
, dateTo
, status
, userId
, faxNumber
, limit
, offset
Resend a Fax
$client->outbound->resend($id[,$newNumber])
Resend the fax identified by the given id (optionally to a new fax number).
Returns a new Interfax\Outbound\Fax
representing the newly created outbound fax.
Inbound
Resend to email
has an property that supports the API endpoints for receiving faxes, as described in the Documentation
Get inbound fax list
$inbound->incoming($options = []);
Retrieves a user's list of inbound faxes.
Get inbound fax record
$inbound->find($id);
Retrieves a single fax's metadata (receive time, sender number, etc.).
null is returned if the resource is not found. Note that this could be because the user is not permissioned for the specific fax.
Get inbound fax image
$inbound->find($id)->image()
The image is retrieved via a method on the inbound fax object.
Get forwarding emails
$inbound->find($id)->emails()
The forwarding email details are retrieved via a method on the inbound fax object.
The returned array is a reflection of the values returned from the emails endpoint of the REST API:
Mark as read/unread
$inbound->find($id)->markRead();
$inbound->find($id)->markUnread();
The inbound fax object provides methods to change the read status.
Resend inbound fax
$inbound->find($id)->resend();
The resend method is on the inbound fax object.
Documents
Cancel
The class allows for the uploading of larger files for faxing. The following is an example of how one should be created:
Create document
Upload chunk
Note no verification of data takes place - an exception wil be raised if values do not match appropriately.
Document properties
As per the documentation a Document has a number of properties which are accessible:
Cancel document
$document->cancel(); //returns the $document instance
Can be done prior to completion or afterward
Helper Classes
Outbound Fax
The Interfax\Outbound\Fax
class wraps the details of any fax sent, and is returned by most of the methods.
It offers several methods to manage or retrieve information about the fax.
Outbound fax properties
Properties on the Fax vary depending on which method call has been used to create the instance. Requesting a property that has not been received will raise a SPL
These are all accessible on a fax instance:
Note values will all be returned as strings.
For convenience, a hash array of the properties can be retrieved
Status should always be available. The values of the status codes are Documented here
Inbound Fax
The incoming equivalent of the outbound fax class, the class wraps the details of any incoming fax, and is returned by the methods where appropriate.
Query parameters
Where methods support a hash array structure of query parameters, these will be passed through to the API endpoint as provided. This ensures that any future parameters that might be added will be supported by the API as is.
The only values that are manipulated are booleans, which will be translated to the text 'TRUE' and 'FALSE' as appropriate.
Exceptions
Any method call that involves a call to the Interfax RESTful API may throw an instance of .
An exception is thrown for any requests that do not return a successful HTTP Status code. The goal of this Exception is to provide a convenience wrapper around information that may have been returned.
Certain responses from the API will provide more detail, and where this occurs, it will be appended to the message of the Exception.
Contributing
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes
Which version of the library?
Functionality for the API in both versions of the library should be the same, and its therefore intended that the core code continues to be the same in both versions. The differences primarily exist to enable continuity of test coverage as PHP evolves (and phpunit evolves with it)
As such, the core functionality should be developed in a way that will work with PHP 5.6 and up, and be consistent in both versions. Usage of newer language features in PHP will not be accepted in the core code.
Running tests
Ensure that composer is installed, then run the following commands.
License
This library is released under the MIT License.