radoslavius/pace-api-bundle

Symfony Bundle for use EFI Pace API Client

dev-master 2021-04-19 22:32 UTC

This package is auto-updated.

Last update: 2021-04-19 22:32:50 UTC


README

This bundle integrates the unofficial PHP client library for EFI Pace's SOAP API into Symfony.

Installation

Install via Composer:

$ composer require radoslavius/pace-api-bundle:dev-master

Add Bundle to AppKernel

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Radoslavius\PaceApiBundle\PaceApiBundle(),
        );
    }
}

Configure

# app/config/config.yml
pace_api:
    host: ip or hostname of your pace installation
    user: username
    password: password
    scheme: http

Code example

$client = $this->get('pace_api.client');
$contact = $client->contact->read(6717);
VarDumper::dump($contact->getTags());
$contact->addTag(5003);
$contact->save();

$contacts = $client->contact->filter('@customer', $contact->customer)->find();
foreach ($contacts as $contact) {
    VarDumper::dump($contact);
}

Toolbar and profiler output in dev

Chart

Chart

Changelog

2021-04-19 - speed optimization

  • add lazyRead method
  • add readFromDb method for some objects
    • BillOfLading
    • Carton
    • CartonContent
    • Contact
    • Job
    • JobContact
    • JobMaterial
    • JobShipment
  • add parameter onlyDirty to save method

Optional config parameters for caching keys and read models from database:

    cacheDir: "%kernel.cache_dir%"
    paceDatabaseConnection: "@doctrine.dbal.pacedb_connection"

Examples:

switch ($test) {
    case 1: // standard behavior
        $job = $pc->job->read(self::FIRST_JOB + $repetition - 1);
        $job->description = $desc;
        $job->save(false);
        break;

    case 2: // read specific attribute from db and update
        $job = $pc->job->readFromDb(self::FIRST_JOB + $repetition - 1, ['description']);
        $readDesc = $job->description;
        $job->description = $desc;
        $job->save();
        break;

    case 3: // only update
        $job = $pc->job->lazyRead(self::FIRST_JOB + $repetition - 1);
        $job->description = $desc;
        $job->save();
        break;

    case 4: // read all attributes on access attribute from db and update
        $job = $pc->job->lazyRead(self::FIRST_JOB + $repetition - 1);
        $readDesc = $job->description;
        $job->description = $desc;
        $job->save();
        break;

    case 5: // do nothing with soap api
        $job = $pc->job->lazyRead(self::FIRST_JOB + $repetition - 1);
        $job->save();
        break;
}

Testing - change description of job on 20 different jobs:

+---------------------------------------------------------------+--------------+
| Test                                                          | Average time |
+---------------------------------------------------------------+--------------+
| 1: standard behavior                                          | 190.2        |
| 2: read specific attribute from db and update                 | 105.2        |
| 3: only update                                                | 67.3         |
| 4: read all attributes on access attribute from db and update | 104.8        |
| 5: do nothing with soap api                                   | 0            |
+---------------------------------------------------------------+--------------+