hurah/canvas-api

A set of classes that helps with communicating with the Instructure Canvas API.

v1.0.9 2025-02-13 09:31 UTC

This package is auto-updated.

Last update: 2025-02-13 09:51:17 UTC


README

Latest Stable Version License CircleCI Build

This library is a PHP SDK for the Instructure Canvas API, designed to simplify communication with Canvas by providing statically typed classes for most API endpoints. It supports both collection and single entity operations. The SDK is still in development but is already being used in small production environments.

Features

  • Statically Typed Classes: Provides typed classes for most API endpoints.
  • Collections and Entities: Easily handle both collections and single entities.
  • Centralized Communication: All communication goes through an instance of the Canvas object.
  • Symfony Console Commands: Includes commands for manual communication with the API, offering examples and testing tools.

Installation

Install the package via Composer:

composer require hurah/canvas-api

Usage

Basic Setup

Create an instance of the Canvas object and authenticate with your API credentials:

use Hurah\CanvasApi\Canvas;

$canvas = new Canvas('your-api-url', 'your-access-token');

Fetching Data

Example: fetch a collection

use Hurah\CanvasApi\Canvas;

$oCourseCollection = $canvas->getCourses();
foreach ($oCourseCollection as $oCourse) {
    echo $oCourse->getName();
}

Example: Single Entity

$oCourse = $canvas->getCourse(123);
echo $course->getName();

Example: Create a new Entity

$oCourse = new Course();
$oCourse->setName('Some name');
$oCourse->setDescription('Some description');
$oCourse->setSomeOtherProperty('...')
$oCourse = $canvas->createCourse($oCourse);

// The same object is returned containing the course
// id and other default properties.
$oCourse->getId() 

Contributing

Contributions and feedback are welcome! Please keep in mind that this software is in beta and comes as is. Use it at your own risk.

  1. Fork the repository.
  2. Create your feature branch: git checkout -b feature/my-new-feature.
  3. Commit your changes: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature/my-new-feature.
  5. Open a pull request.

Links

Author

Anton Boutkam - Teacher Software Development at ROC Amstelland

CicleCI build status

CircleCI

v1.0.3 added Quiz v1.0.5 updated Quiz v1.0.6 updated QuizQuestionGroup v1.0.7 updated QuizQuestionGroup v1.0.8 updated QuizQuestion