Requirements

Installing the library

The recommended installation method is by using Composer and Docker. If are unable to use Composer and Docker for your project, you can still install the SDK manually by downloading the source files and including the autoloader.

1. Composer installation

The following script is tested in a Debian Linux based distribution. Execute this line in your Linux terminal if you still do not have installed composer.

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

# update composer to verify everything is ok
composer update

At this point, you will have to decide if you want to let the SDK the labor of creating a base project structure, or you prefer to add to the composer.json of your project the required dependencies. The first option (A) is recommended in case of you want to have the library running as fast as possible, because you will have the log and cache paths, properly configured.  It is also recommended if you are starting a project from scratch. The (B) option is recommended in case of you already have experience with the library and need to add the integration to your project.

Option A) Create base project using composer (recommended)

Execute this commad:

composer --repository-url="https://raw.githubusercontent.com/dru-id/druid-php-skel/master" --dev create-project druid/php-skel

And that´s all. Now you can create a file index.php, and paste the following code

Option B) Add  DRUID SDK dependencies manually to your composer.json

1. Add composer dependencies

Add the following “require” entry to the composer.json  file in the root of your project.

{
  "require": {
    "druid/php-sdk": "dev-master"
  }
}

And add the following repository to the same the composer.json  file in the root of your project.

"repositories": [{
    "type": "vcs",
    "url": "https://github.com/dru-id/druid-php-sdk"
  }],

An example of the entire composer.json  file of your project should look like this:

{
  "name": "mycompany/myproject",
  "version": "1.0.0",
  "description": "My awesome php site integrated with DRUID",
  "repositories": [{
    "type": "vcs",
    "url": "https://github.com/dru-id/druid-php-sdk"
  }],
  "require": {
    "druid/php-sdk": "dev-master"
  }
}

Then run composer install  from the command line, and composer will download the latest version of the SDK and put it in the /vendor/ directory.

2. Add oauthconf.xml file to site-config/dev folder

This file contains the credentials of your app, so it is required to run the library. The library must have  the configuration file just “as is” when you download via cockpit. A configuration file must be set for each of the environments where the library is executed, which should be saved in a folder that indicates the environment.

IMPORTANT: the site-config folder must NEVER be housed in a public directory and accessible via URL: It must always be protected against reading or it must be located outside the site’s publication directory. Bear in mind that with this file, a malicious user who knows the URL of the file would be able to consult personal data on any user registered with DRUID.

Location of this folder is defined through vendor/druid/php-sdk/config/druid.ini file.

DRUID provides the developer 2 environments:

  • Test environment :  The configuration file provided for this environment will be saved in the /test folder and the site-config/dev folder. This means that you
  • Production environment: The environment where you should note your production environment. The configuration file provided for this environment will be saved in the site-config/prod folder.

Note: the environment where the application is being executed can be specified through the vendor/druid/php-sdk/config/druid.ini .

3. Configure CACHE_PATH , LOG_PATH  and CONF_PATH

These variables are located inside druid.ini  file which is located inside the vendor/druid/php-sdk/config/ folder you moved in the previous step.

CACHE_PATH  is the path in which the temporally files are going to be stored.

LOG_PATH  is the path of the logfiles.

CONF_PATH  is the path of the oauthconf.xml  file.

Download the SDK: