This file provides more detail as to how to install the Interfax PHP library in a project.
The standard approach is to use the composer dependency manager to add the library to your project requirements:
composer require interfax/interfax
Many projects may not use composer to manage their dependencies. In these circumstances, it's possible to include the library as a self contained dependency. The following steps will allow you to do this.
- Clone the Interfax PHP repo into your project.
- Inside the Interfax PHP directory, download composer.
- Run composer to download the dependencies for the Interfax library.
- Back in your main project file(s), include the autoload file generated by composer to include the library and its dependencies.
- Follow the documentation to use the library as normal.
Assuming a simple project for Acme Corp that consists of a single index.php
file.
cd acme-corp
git clone https://github.com/interfax/interfax-php.git
cd interfax-php
Assuming composer is not already installed globally, install it into a bin directory.
mkdir bin
Note the composer site has more detailed instructions for installation, the following is a small simplification
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=bin
php -r "unlink('composer-setup.php');"
Simply run the install command to download the dependencies
php ./bin/composer.phar install --no-dev
The 'no-dev' option prevents the testing dependencies for the library from being installed to save space/bandwidth
inside acme-corp/index.php
require_once(__DIR__ . '/interfax-php/vendor/autoload.php');
use Interfax\Client;
$interfax = new Client(['username' => 'username', 'password' => 'password']);
// etc
When it comes to deploying the project, the following paths will be required:
acme-corp/interfax-php/src/
acme-corp/interfax-php/vendor/
The rest of the files can safely be ignored.