2017 © Pedro PelΓ‘ez
 

laravel vtiger

Package to run Vtiger Webservice API

image

clystnet/vtiger

Package to run Vtiger Webservice API

  • Sunday, July 15, 2018
  • by Clystnet
  • Repository
  • 2 Watchers
  • 2 Stars
  • 112 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 14 Versions
  • 239 % Grown

The README.md

This package is deprecated

### Here at Clystnet We no longer maintain the Open Source version of this package. We do however maintain our in house version of this package which you talk to us about using by contacting sales@clystnet.com., (*1)

# Vtiger (Laravel 5 Package) All Contributors Use the Vtiger webservice (REST) API from within Laravel for the following operations., (*2)

  • Create
  • Retrieve
  • Update
  • Delete
  • Search
  • Query
  • Describe

See Third Party App Integration (REST APIs), (*3)

Installation, Configuration and Usage

Installing

  1. In order to install the Vtiger package in your Laravel project, just run the composer require command from your terminal:, (*4)

    composer require "clystnet/vtiger ^1.4"
    

    If you are using Laravel >= 5.5 you don’t need to do steps 2 and 3., (*5)

  2. Then in your config/app.php add the following to the providers array:, (*6)

    Clystnet\Vtiger\VtigerServiceProvider::class,
    
  3. In the same config/app.php add the following to the aliases array:, (*7)

    'Vtiger' => Clystnet\Vtiger\Facades\Vtiger::class,
    
  4. Publish the configuration file:, (*8)

    php artisan vendor:publish --tag="vtiger"
    

Configuration

  • In Vtiger, create a new or select an existing user.
  • Under User Advanced Options make note of the username and access key.
  • In your application, edit config/vtiger.php and replace the following array values, (*9)

    • Set the url to the https://{DOMAIN_NAME}/webservice.php
    • Set the username and accesskey with your CRM username and access key.
    • Set persistconnection to false if you want a fresh login with each request
    key value
    url http://www.example.com/webservice.php
    username API
    accesskey irGsy9HB0YOZdEA
    persistconnection true
    max_retries 10

Because I've experienced problems getting the sessionid from the CRM when multiple users are accessing the CRM at the same time, the solution was to store the sessionid into a file within Laravel application. Instead of getting the token from the database for each request using the webservice API, a check is made against the expiry time in the file. If the expiry time has expired, a token is requested from the CRM and file is updated with the new token and updated expiry time., (*10)

Usage

In your controller include the Vtiger package, (*11)

use Vtiger;

Create

To insert a record into the CRM, first create an array of data to insert. Don't forget the added the id of the assigned_user_id (i.e. '4x12') otherwise the insert will fail as assigned_user_id is a mandatory field., (*12)

$data = array(
    'assigned_user_id' => '',
);

To do the actual insert, pass the module name along with the json encoded array to the create function., (*13)

Vtiger::create($MODULE_NAME, json_encode($data));

Retrieve

To retrieve a record from the CRM, you need the id of the record you want to find (i.e. '4x12')., (*14)

$id = '4x12';

$obj = Vtiger::retrieve($id);

// do someting with the result
var_dump($obj);

Update

The easiest way to update a record in the CRM is to retrieve the record first., (*15)

$id = '4x12';

$obj = Vtiger::retrieve($id);

Then update the object with updated data., (*16)

$obj->result->field_name = 'Your new value';

$update = Vtiger::update($obj->result);

Delete

To delete a record from the CRM, you need the id of the record you want to delete (i.e. '4x12')., (*17)

$id = '4x12';

$obj = Vtiger::retrieve($id);

// do someting with the result
var_dump($obj);

Lookup

This function uses the Vtiger Lookup API endpoint to search for a single piece of information within multiple columns of a Vtiger module. This function is often multitudes faster than the search function., (*18)

    $dataType = 'phone';
    $phoneNumber = '1234567890';
    $module = 'Leads';
    $columns = ['phone', 'fax']; //Must be an array

    Vtiger::lookup($dataType, $phoneNumber, $module, $columns);

This function is a sql query builder wrapped around the query function. Accepts instance of laravels QueryBuilder., (*19)

$query = DB::table('Leads')->select('id', 'firstname', 'lastname')->where('firstname', 'John');

$obj = Vtiger::search('Leads', $query);

//loop over result
foreach($obj->result as $result) {
    // do something
}

By default the function will quote but not escape your inputs, if you wish for your data to not be quoted, set the 3rd paramater to false like so:, (*20)

$obj = Vtiger::search('Leads', $query, false);

Also keep in mind that Vtiger has several limitations on it's sql query capabilities. You can not use conditional grouping i.e "where (firstname = 'John' AND 'lastname = 'Doe') OR (firstname = 'Jane' AND lastname = 'Smith') will fail., (*21)

Query

To use the Query Operation, you first need to create a SQL query., (*22)

$query = "SELECT * FROM ModuleName;";

Then run the query..., (*23)

$obj = Vtiger::query($query);

//loop over result
foreach($obj->result as $result) {
    // do something
}

Describe

To describe modules in the CRM run this with the module name, (*24)

$moduleDescription = (Vtiger:describe("Contacts"))->result;

Contributing

Please report any issue you find in the issues page. Pull requests are more than welcome., (*25)

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details, (*26)

Contributors ✨

Thanks goes to these wonderful people (emoji key):, (*27)

, (*28)


Ahmad Syamim

πŸ’»

Clyde Cox

πŸ’» πŸ“–

Christopher Pratt

πŸ’» πŸ“–

adam-godfrey

πŸ’» πŸ“–

, (*29)

This project follows the all-contributors specification. Contributions of any kind welcome!, (*30)

The Versions

15/07 2018

dev-master

9999999-dev https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

15/07 2018

1.5.1

1.5.1.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

09/07 2018

1.5.0

1.5.0.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

22/06 2018

1.4.6

1.4.6.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

15/06 2018

1.4.5

1.4.5.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

15/06 2018

1.4.4

1.4.4.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

15/06 2018

1.4.3

1.4.3.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

15/06 2018

1.4.2

1.4.2.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

14/06 2018

1.4.1

1.4.1.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

13/06 2018

1.4

1.4.0.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

09/05 2018

1.3

1.3.0.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

03/05 2018

1.2

1.2.0.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

09/04 2018

1.1

1.1.0.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

 

laravel vtiger

05/04 2018

1.0

1.0.0.0 https://github.com/Clystnet/Vtiger

Package to run Vtiger Webservice API

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

laravel vtiger