PHPackages                             bakaphp/canvas-sdk-php - 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. bakaphp/canvas-sdk-php

AbandonedArchivedLibrary

bakaphp/canvas-sdk-php
======================

A PHP client library for accessing Kanvas APIs

0.2.x-dev(5y ago)3750[10 issues](https://github.com/bakaphp/canvas-sdk-php/issues)MITPHPPHP &gt;=7.2

Since Dec 6Pushed 3y ago4 watchersCompare

[ Source](https://github.com/bakaphp/canvas-sdk-php)[ Packagist](https://packagist.org/packages/bakaphp/canvas-sdk-php)[ Docs](https://github.com/bakaphp/canvas-sdk-php)[ RSS](/packages/bakaphp-canvas-sdk-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (8)Versions (12)Used By (0)

Kanvas APIs client library for PHP
==================================

[](#kanvas-apis-client-library-for-php)

The Kanvas PHP library provides convenient access to the Kanvas API from applications written in the PHP language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Kanvas API. This SDK is based on Stripe SDK (thanks stripe)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9c90d68dff285387a9ab92a236b9c3c94df6e19dcbe7c05a272aed1c329d7ead/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62616b617068702f63616e7661732d73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bakaphp/canvas-sdk-php)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ba7b071fbc92c99d0ef388634bbcd367135285d38c0b95edc42d672ce7b9b9f7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f62616b617068702f63616e7661732d73646b2d7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bakaphp/canvas-sdk-php)[![Coverage Status](https://camo.githubusercontent.com/2058f01404551b43f74aabb61b7d31d692b6ab0da5a0e5e82134a05e5f9a0fb4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f62616b617068702f63616e7661732d73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bakaphp/canvas-sdk-php/code-structure)[![Quality Score](https://camo.githubusercontent.com/1619657b336c1eb2646b5eef657eed09cd34ff07eea0fb44ce4cadcd584f77b5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f62616b617068702f63616e7661732d73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bakaphp/canvas-sdk-php)[![Total Downloads](https://camo.githubusercontent.com/8f21da3ff835f253ca33b248785605828a0ee017c49412e7a37c6d507498b05f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62616b617068702f63616e7661732d73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bakaphp/canvas-sdk-php)

A PHP client library for accessing Canvas APIs

Install
-------

[](#install)

Via Composer

```
$ composer require bakaphp/canvas-sdk-php
```

Usage
-----

[](#usage)

```
use Kanvas\Sdk\Auth;
use Kanvas\Sdk\Kanvas;
Kanvas::setApiKey($appApiKey);
Auth::auth([
        'email' => 'kanvas@mctekk.com',
        'password' => 'somethingpassword'
]);

//Call Kanvas Functions
```

Set the token on your DI

```
use Kanvas\Sdk\Auth;
use Kanvas\Sdk\Kanvas;
Kanvas::setApiKey($appApiKey);
Kanvas::setAuthToken($request['token']);

//Call Kanvas Functions
```

Using Resources
---------------

[](#using-resources)

Every Kanvas SDK resource work in the same way. All of them have CRUD capabilites and some of them have custom functions that can be accessed as static functions. Furthermore, here is how a CRUD of a resource works:

### Create

[](#create)

```
use Kanvas\Sdk\Users;

Users::create([
    'firstname'=>'testSDK',
    'lastname'=> 'testSDK',
    'displayname'=> 'sdktester',
    'password'=> 'nosenose',
    'default_company'=> 'example sdk',
    'email'=> 'examplesd5k@gmail.com',
    'verify_password'=> 'nosenose'
    ]);
```

### Update

[](#update)

```
Users::update('id',[
    'firstname'=>'testSDK',
    'lastname'=> 'testSDK',
    ]);
```

### Delete

[](#delete)

```
Users::delete('id');
```

### List

[](#list)

```
Users::all([], []);
```

### Retrieve

[](#retrieve)

```
Users::retrieve('id', [], ['relationships'=>['roles']]);
```

Custom queries on CRUD operations
---------------------------------

[](#custom-queries-on-crud-operations)

In addition to the usual functionalities of every resource CRUD operation, other parameters can be used to make custom queries. An example of this can be seen on the retrieve operation example.

Currently we only support Phalcon's type of querying database tables. We work with:

- conditions
- limit
- order

Phalcon Passthrough
-------------------

[](#phalcon-passthrough)

To use the Phalcon Passthrough it must first be called as trait in your project's controller. The controller itself could be named whatever you want but the default name given is `ApiController`. Furthermore, the controller should extend from the Baka Http `BaseController`.

```
use Baka\Http\Api\BaseController as BakaBaseController;
use Kanvas\Sdk\Passthroughs\PhalconPassthrough;
use Phalcon\Http\Response;

class ApiController extends BakaBaseController
{
    use PhalconPassthrough;
}
```

The trait itself has a function called `transporter` which is in charge of making a request to the Kanvas API. Two functions must be created; one to be called by private routes and the other by public routes. They could be as follows:

```
use PhalconPassthrough;

public function publicTransporter(): Phalcon\Http\Response
{
    return $this->transporter();
}
public function privateTransporter(): Phalcon\Http\Response
{
    return $this->transporter();
}
```

Both functions should return a Phalcon Response.

### Setup of Passthrough Routes

[](#setup-of-passthrough-routes)

There are two options for setting up the passthrough routes. The first one implies calling both PublicRoutes.php(contains the default Kanvas public routes) and PrivateRoutes.php(contains the default Kanvas private routes) directly on your own routes setup.

```
use Kanvas\Sdk\Routes\PrivateRoutes;
use Kanvas\Sdk\Routes\PublicRoutes;
```

The second one requires the creation of two files(one for public routes and one for private routes) that return the desired Kanvas routes as an array. These files should be as follows:

```
use Baka\Router\Route;

return [
    Route::crud('/users')->controller('ApiController')->action('privateTransporter')->notVia('post'),
    Route::crud('/companies')->controller('ApiController')->action('privateTransporter'),
    Route::crud('/roles')->controller('ApiController')->action('privateTransporter'),
    Route::crud('/locales')->controller('ApiController')->action('privateTransporter'),
    Route::crud('/currencies')->controller('ApiController')->action('privateTransporter'),
    Route::crud('/apps')->controller('ApiController')->action('privateTransporter')
    ]
```

The files must return array and every route should be a Baka Router Route.

After that, whichever option you choose should use the RouteConfigurator which has two functions for merging your own routes with the Kanvas ones.

```
use Kanvas\Sdk\Routes\RouteConfigurator;

$publicRoutes = RouteConfigurator::mergePublicRoutes($publicRoutes, appPath('api/routes/publicRoutes.php'));
$privateRoutes = RouteConfigurator::mergePrivateRoutes($privateRoutes, appPath('api/routes/privateRoutes.php'));
```

`mergePublicRoutes` merges Kanvas public routes with your own public routes. It also takes the path to the custom public routes file defined by you.

`mergePrivateRoutes` merges Kanvas private routes with your own private routes. It also takes the path to the custom private routes file defined by you.

Both functions return a merged array.

SDK Models
----------

[](#sdk-models)

This SDK also provides search by Kanvas Users and Companies. These two models will make a request to the Kanvas API and work just like a typical Phalcon model which has the `find` and `findFirst` functions.To use them do as follows:

```
use Kanvas\Sdk\Users;
use Kanvas\Sdk\Companies;

Users::find():

Users::findFirst([
    'conditions'=> 'email = ?0'
    'bind'=>[example]
]);

Companies::find();

Companies::findFirst([
    'conditions'=> 'email = ?0'
    'bind'=>[example]
]);
```

As said before, both models work as a Phalcon model, they work with all the parameters that can be given to them.

`Notice`: You must be authenticated to use this models and your API key must also be set.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.6% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/136c850ea7ec76b23cc5b1fed8507683cc891145cffedc7761fe73ce03960df3?d=identicon)[mctekk](/maintainers/mctekk)

---

Top Contributors

[![rwhite27](https://avatars.githubusercontent.com/u/29263079?v=4)](https://github.com/rwhite27 "rwhite27 (151 commits)")[![kaioken](https://avatars.githubusercontent.com/u/118385?v=4)](https://github.com/kaioken "kaioken (50 commits)")[![arfenis](https://avatars.githubusercontent.com/u/23733749?v=4)](https://github.com/arfenis "arfenis (3 commits)")[![leninpaulino](https://avatars.githubusercontent.com/u/16233649?v=4)](https://github.com/leninpaulino "leninpaulino (3 commits)")[![jesusantguerrero](https://avatars.githubusercontent.com/u/17421742?v=4)](https://github.com/jesusantguerrero "jesusantguerrero (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bakaphp-canvas-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/bakaphp-canvas-sdk-php/health.svg)](https://phpackages.com/packages/bakaphp-canvas-sdk-php)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M256](/packages/laravel-dusk)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)[netflie/whatsapp-cloud-api

The first PHP SDK to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

640431.7k4](/packages/netflie-whatsapp-cloud-api)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)

PHPackages © 2026

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