PHPackages                             dangkien/phpsdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dangkien/phpsdk

ActiveLibrary

dangkien/phpsdk
===============

phpsdk

00PHP

Since Feb 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/DangKien/K_SDK)[ Packagist](https://packagist.org/packages/dangkien/phpsdk)[ RSS](/packages/dangkien-phpsdk/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Bizfly Sdk
==========

[](#bizfly-sdk)

Cài đặt
-------

[](#cài-đặt)

```
    composer require bizflycrm/phpsdk

```

Bizfly CRM
----------

[](#bizfly-crm)

#### API Key:

[](#api-key)

*Có thể lấy thông tin api [tại đây](https://crm.bizfly.vn/project/api)*

- **API\_KEY**: Đây là api key do CRM Bizfly cung cấp.
- **API\_SECRET**: Đây là đoạn mã secret do CRM Bizfly cung cấp.
- **API\_EMBED**: Đây là đoạn mã embed do CRM Bizfly cung cấp.
- **PROJECT\_TOKEN**: Đây là project token do My Bizfly cung cấp. Dùng cho toàn bộ giải pháp của Bizfly. Có thể lấy

#### Khởi tạo Client SDK

[](#khởi-tạo-client-sdk)

```
    use BizflyCrmSdk\CrmClient;
    $config = [
        'api_key' => API_KEY,
        'api_secret' => API_SECRET,
        'api_embed' => API_EMBED,
        'project_token' => PROJECT_TOKEN,
    ];
    $client = new CrmClient($config);
```

### Lấy đối tượng khách hàng

[](#lấy-đối-tượng-khách-hàng)

```
    $customer = $client->getTableCustomer();
```

#### Lấy danh sách khách hàng: `find()`

[](#lấy-danh-sách-khách-hàng-find)

```
     $customer->find([
            'limit' => 100,
            'skip' => 0,
            'select' => ["name", "created_at"],
            'output' => "default",
        ]);
```

#### Tìm kiếm khách hàng theo ID: `find()`

[](#tìm-kiếm-khách-hàng-theo-id-find)

```
     $customer->find([
            'limit' => 100,
            'skip' => 0,
            'query' => [
                'id' => ['id_ban_ghi']
            ],
            'select' => ["name", "created_at"],
            'output' => "default",
        ]);
```

#### Thêm mới bản ghi khách hàng: `update()`

[](#thêm-mới-bản-ghi-khách-hàng-update)

```
    $customer->update([
            "data" => [
                [
                    "fields" => [
                        [
                            "key" => "name",
                            "value" => "Nguyễn Duy Sự"
                        ],
                        [
                            "key" => "emails",
                            "value" => [
                                [
                                    "value" => "su.nguyenduy.api1@gmail.com"
                                ]
                            ]
                        ],
                        [
                            "key" => "phones",
                            "value" => [
                                [
                                    "value" => "0987654321"
                                ],
                                [
                                    "value" => "0987654322"
                                ]
                            ]
                        ]

                    ],
                ]
            ]
    ]);
```

#### Cập nhật bản ghi khách hàng theo ID: `id: ''`

[](#cập-nhật-bản-ghi-khách-hàng-theo-id-id-)

```
    $customer->update([
            "data" => [
                [
                    "fields" => [
                        [
                            "key" => "name",
                            "value" => "Nguyễn Duy Sự"
                        ],
                        [
                            "key" => "emails",
                            "value" => [
                                [
                                    "value" => "su.nguyenduy.api1@gmail.com"
                                ]
                            ]
                        ],
                        [
                            "key" => "phones",
                            "value" => [
                                [
                                    "value" => "0987654321"
                                ],
                                [
                                    "value" => "0987654322"
                                ]
                            ]
                        ]

                    ],
                    "id" => 'id_ban_ghi_can_update'
                ]
            ]
    ]);
```

#### Cập nhật bản ghi khách hàng nếu trùng: `mapingBy: []`

[](#cập-nhật-bản-ghi-khách-hàng-nếu-trùng-mapingby-)

- *Nếu bản ghi trùng email và phones thì cập nhật lại bản ghi cũ*

```
    $customer->update([
            "data" => [
                [
                    "mapingBy" => ["emails", "phones"],
                    "fields" => [
                        [
                            "key" => "name",
                            "value" => "Nguyễn Duy Sự"
                        ],
                        [
                            "key" => "emails",
                            "value" => [
                                [
                                    "value" => "su.nguyenduy.api1@gmail.com"
                                ]
                            ]
                        ],
                        [
                            "key" => "phones",
                            "value" => [
                                [
                                    "value" => "0987654321"
                                ],
                                [
                                    "value" => "0987654322"
                                ]
                            ]
                        ]

                    ],
                    "id" => 'id_ban_ghi_can_update'
                ]
            ]
    ]);
```

#### Lấy thông tin các trường dữ liệu trong bảng khách hàng: `struct()`

[](#lấy-thông-tin-các-trường-dữ-liệu-trong-bảng-khách-hàng-struct)

```
    $customer->struct();
```

#### Thêm mới các trường dữ liệu bảng khách hàng: `addFields()`

[](#thêm-mới-các-trường-dữ-liệu-bảng-khách-hàng-addfields)

```
      $customer->addFields([
           "data" => [
           "fields" => [
                   [
                       "key" => "field_1",
                       "type" => "string",
                       "label" => "Trường thứ 1",
                       "description" => "Mô tả trường thứ 1"
                   ],
                   [
                       "key" => "field_2",
                       "type" => "array-object",
                       "label" => "Trường thứ 2",
                       "description" => "Mô tả trường thứ 2"
                   ],
               ]
           ]
       ]);
```

#### Lấy 'danh sách' trong bảng khách hàng: `getLists()`

[](#lấy-danh-sách-trong-bảng-khách-hàng-getlists)

```
    $customer->getLists([
        'limit' => 100,
        'skip' => 0,
        'output' => "default",
        'sort' => [
            'count' => 1
        ]
    ]);
```

#### Thêm 'danh sách' trong bảng khách hàng: `addLists()`

[](#thêm-danh-sách-trong-bảng-khách-hàng-addlists)

```
    $customer->addLists([
        "data" => [
            [
                "value" => "Danh sách 1"
            ],
            [
                "value" => "Danh sách 2"
            ]
        ]
    ]);
```

### Lấy đối tượng Deal

[](#lấy-đối-tượng-deal)

```
    $deal = $client->getTableDeal();
```

#### Lấy danh sách Deal: `find()`

[](#lấy-danh-sách-deal-find)

```
     $deal->find([
        'limit' => 100,
        'skip' => 0,
        'select' => ["name", "created_at"],
        'output' => "default",
     ]);
```

#### Tìm kiếm Deal theo ID: `find()`

[](#tìm-kiếm-deal-theo-id-find)

```
     $deal->find([
            'limit' => 100,
            'skip' => 0,
            'query' => [
                'id' => ['id_ban_ghi']
            ],
            'select' => ["name", "created_at"],
            'output' => "default",
        ]);
```

#### Thêm mới bản ghi Deal: `update()`

[](#thêm-mới-bản-ghi-deal-update)

```
    $deal->update([
            "data" => [
                [
                    "fields" => [
                        [
                            "key" => "name",
                            "value" => "Deal Test"
                        ],
                        [
                            "key" => "customer",
                            "value" => [
                                    [
                                        "id" => "5e967a9f84f36615d4007365"
                                    ]
                            ]
                        ],
                        [
                            "key" => "code",
                            "value" => "05182020"
                        ],
                        [
                            "key" => "sale",
                            "value" => [
                                [
                                    "id" => "5e8ed4245adfc61f960fb793"
                                ]
                            ]
                        ],
                        [
                             "key" => "amount",
                             "value" => 10000000
                        ],
                        [
                            "key" => "rating",
                            "value" => 90
                        ],
                    ],
                ]
            ]
    ]);
```

#### Cập nhật bản ghi Deal theo ID: `id: ''`

[](#cập-nhật-bản-ghi-deal-theo-id-id-)

```
    $deal->update([
            "data" => [
                [
                    "fields" => [
                        [
                            "key" => "name",
                            "value" => "Deal Test"
                        ],
                        [
                            "key" => "customer",
                            "value" => [
                                    [
                                        "id" => "5e967a9f84f36615d4007365"
                                    ]
                            ]
                        ],
                        [
                            "key" => "code",
                            "value" => "05182020"
                        ],
                        [
                            "key" => "sale",
                            "value" => [
                                [
                                    "id" => "5e8ed4245adfc61f960fb793"
                                ]
                            ]
                        ],
                        [
                             "key" => "amount",
                             "value" => 10000000
                        ],
                        [
                            "key" => "rating",
                            "value" => 90
                        ],
                    ],
                    "id" => "id_ban_ghi_cap_nhat"
                ]
            ]
    ]);
```

#### Cập nhật bản ghi Deal nếu trùng: `mapingBy: []`

[](#cập-nhật-bản-ghi-deal-nếu-trùng-mapingby-)

- *Nếu bản ghi trùng code thì cập nhật lại bản ghi cũ*

```
    $deal->update([
            "mappingBy" => ["code"],
            "data" => [
                [
                    "fields" => [
                        [
                            "key" => "name",
                            "value" => "Deal Test"
                        ],
                        [
                            "key" => "customer",
                            "value" => [
                                    [
                                        "id" => "5e967a9f84f36615d4007365"
                                    ]
                            ]
                        ],
                        [
                            "key" => "code",
                            "value" => "05182020"
                        ],
                        [
                            "key" => "sale",
                            "value" => [
                                [
                                    "id" => "5e8ed4245adfc61f960fb793"
                                ]
                            ]
                        ],
                        [
                             "key" => "amount",
                             "value" => 10000000
                        ],
                        [
                            "key" => "rating",
                            "value" => 90
                        ],
                    ],
                ]
            ]
        ]);
```

#### Lấy thông tin các trường dữ liệu trong bảng Deal: `struct()`

[](#lấy-thông-tin-các-trường-dữ-liệu-trong-bảng-deal-struct)

```
    $deal->struct();
```

#### Thêm mới các trường dữ liệu bảng Deal: `addFields()`

[](#thêm-mới-các-trường-dữ-liệu-bảng-deal-addfields)

```
      $deal->addFields([
           "data" => [
           "fields" => [
                   [
                       "key" => "field_1",
                       "type" => "string",
                       "label" => "Trường thứ 1",
                       "description" => "Mô tả trường thứ 1"
                   ],
                   [
                       "key" => "field_2",
                       "type" => "array-object",
                       "label" => "Trường thứ 2",
                       "description" => "Mô tả trường thứ 2"
                   ],
               ]
           ]
       ]);
```

### Lấy đối tượng hoạt động

[](#lấy-đối-tượng-hoạt-động)

```
    $activity =  $client->getTableActivity();
```

#### Lấy danh sách hoạt động: `find()`

[](#lấy-danh-sách-hoạt-động-find)

```
     $activity->find([
            'limit' => 100,
            'skip' => 0,
            'select' => ["name", "created_at"],
            'output' => "default",
        ]);
```

#### Tìm kiếm hoạt động theo ID: `find()`

[](#tìm-kiếm-hoạt-động-theo-id-find)

```
     $activity->find([
            'limit' => 100,
            'skip' => 0,
            'query' => [
                'id' => ['id_ban_ghi']
            ],
            'select' => ["name", "created_at"],
            'output' => "default",
        ]);
```

#### Thêm mới bản ghi hoạt động: `update()`

[](#thêm-mới-bản-ghi-hoạt-động-update)

```
    $activity->update([
        "data" => [
           'fields' => [
                [
                     "key"  => "name",
                     "value"  => "Khảo sát khách ngày 18-05-2019",
                ],
                [
                     "key" => "customer_id",
                     "value" => "5e8fdfd584f3662b2c003313",
                ],
                [
                    "key" => "emails",
                    "value" => [
                         [
                             "value" => "hieptranmanh@vccorp.vn",
                         ]
                    ]
                ],
                [
                     "key" => "phones",
                     "value" => [
                         [
                             "value" => "+84948981266",
                         ]
                     ]
                ],
                [
                     "key" => "object_name",
                     "value" => "Khảo sát về nhu cầu mua hàng",
                ],
                [
                     "key" => "object_type",
                     "value" => "survey",
                ],
                [
                     "key" => "object_type_label",
                     "value" => "Khảo sát",
                ],
                [
                     "key" => "object_id",
                     "value" => "5e8eb6fc84f3661ef4000668",
                ],
                [
                     "key" => "action",
                     "value" => "input-form",
                ],
                [
                     "key" => "action_label",
                     "value" => "Nhập form online",
                ]
            ]
        ]
    ]);
```

#### Cập nhật bản ghi hoạt động theo ID: `id: ''`

[](#cập-nhật-bản-ghi-hoạt-động-theo-id-id-)

```
    $activity->update([
         "data" => [
            "fields" => [
                [
                     "key"  => "name",
                     "value"  => "Khảo sát khách ngày 18-05-2019",
                ],
                [
                     "key" => "customer_id",
                     "value" => "5e8fdfd584f3662b2c003313",
                ],
                [
                    "key" => "emails",
                    "value" => [
                         [
                             "value" => "hieptranmanh@vccorp.vn",
                         ]
                    ]
                ],
                [
                     "key" => "phones",
                     "value" => [
                         [
                             "value" => "+84948981266",
                         ]
                     ]
                ],
                [
                     "key" => "object_name",
                     "value" => "Khảo sát về nhu cầu mua hàng",
                ],
                [
                     "key" => "object_type",
                     "value" => "survey",
                ],
                [
                     "key" => "object_type_label",
                     "value" => "Khảo sát",
                ],
                [
                     "key" => "object_id",
                     "value" => "5e8eb6fc84f3661ef4000668",
                ],
                [
                     "key" => "action",
                     "value" => "input-form",
                ],
                [
                     "key" => "action_label",
                     "value" => "Nhập form online",
                ]
            ],
            "id" => "id_ban_ghi"
        ]
    ]);
```

#### Lấy thông tin các trường dữ liệu trong bảng hoạt động: `struct()`

[](#lấy-thông-tin-các-trường-dữ-liệu-trong-bảng-hoạt-động-struct)

```
    $activity->struct();
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/00d9e969067d40f8606d7745b5a04f0116dac98634b17111cdbff31a7d7e19c6?d=identicon)[DangKien](/maintainers/DangKien)

---

Top Contributors

[![DangKien](https://avatars.githubusercontent.com/u/21361726?v=4)](https://github.com/DangKien "DangKien (1 commits)")

### Embed Badge

![Health badge](/badges/dangkien-phpsdk/health.svg)

```
[![Health](https://phpackages.com/badges/dangkien-phpsdk/health.svg)](https://phpackages.com/packages/dangkien-phpsdk)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
