animafac/civicrm-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

animafac/civicrm-api

Composer 安装命令:

composer require animafac/civicrm-api

包简介

Library that allows you to easily use the CiviCRM PHP API

README 文档

README

This library allows you to easily use the CiviCRM PHP API.

The civicrm_api3 class is great but it only returns stdClass objects. This library uses full class objects with useful methods and exceptions.

Usage

Classes

The following classes are available:

  • Address
  • Contact
  • ContactType
  • Country
  • Email
  • EntityTag
  • LocationType
  • Note
  • Phone
  • Relationship
  • RelationshipType
  • StateProvince
  • Tag
  • User
  • Website

They all correspond to CiviCRM entities.

Methods

All these classes share a set of common methods.

get

Returns a property from this object.

$contact = new Contact($id);
$contact->get('display_name');

set

Add a property to this object.

$contact = new Contact($id);
$contact->set('display_name');

save

Saves the object to the database

$contact = new Contact();
$contact->set('display_name');
$contact->save();

delete

Removes the object from the database.

$contact = new Contact($id);
$contact->delete();

getAll

Get all objects from this type.

Contact::getAll();

// Or if you only want a subset.
Contact::getAll(['contact_type' => 'Organization']);

getCount

Get the number of objects from this type.

Contact::getCount();

// Or if you only want a subset.
Contact::getCount(['contact_type' => 'Organization']);

getSingle

Get a single object that matches the specified constraints.

Contact::getSingle(['first_name' => 'foo', 'last_name' => 'bar']);

Setup

You can install this library with Composer:

composer require animafac/civicrm-api

Then you need to include both this library (preferably via the Composer autoloader) and the CiviCRM class.api.php file.

use CivicrmApi\Api;
use CivicrmApi\Contact;

require_once __DIR__.'/vendor/autoload.php';
require_once 'path/to/civicrm/api/class.api.php';

Api::$path = '/path/to/civicrm/config/';

$contact = new Contact($id);
echo $contact->get('display_name');

Grunt tasks

Grunt can be used to run some automated tasks defined in Gruntfile.js.

Your first need to install JavaScript dependencies with Yarn:

yarn install
composer install

Lint

You can check that the JavaScript, JSON and PHP files are formatted correctly:

grunt lint

Tests

You can run PHPUnit tests:

grunt test

Documentation

phpDocumentor can be used to generate the code documentation:

grunt doc

CI

Gitlab CI is used to run the tests automatically after each commit.

统计信息

  • 总下载量: 120
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2018-04-18