Download the PHP package jjuanrivvera/canvas-lms-kit without Composer
On this page you can find all versions of the php package jjuanrivvera/canvas-lms-kit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jjuanrivvera/canvas-lms-kit
More information about jjuanrivvera/canvas-lms-kit
Files in jjuanrivvera/canvas-lms-kit
Package canvas-lms-kit
Short Description The most comprehensive PHP SDK for Canvas LMS API. Production-ready with +35 APIs implemented, rate limiting, and full test coverage.
License MIT
Homepage https://github.com/jjuanrivvera/canvas-lms-kit
Informations about the package canvas-lms-kit
โจ Why Canvas LMS Kit?
- ๐ Production Ready: Rate limiting, middleware support, battle-tested
- ๐ Comprehensive: 45 Canvas APIs fully implemented
- ๐ก๏ธ Type Safe: Full PHP 8.1+ type declarations, strict_types, and PHPStan level 6
- ๐ง Developer Friendly: Intuitive Active Record pattern - just pass arrays!
- ๐ Well Documented: Extensive examples, guides, and API reference
- โก Performance: Built-in pagination, caching support, and optimized queries
- ๐ฏ Code Quality: PHP-CS-Fixer integration, PSR-12 compliance
๐ฏ Quick Start
๐ Table of Contents
- Requirements
- Installation
- Configuration
- Usage Examples
- Supported APIs
- Advanced Features
- Testing
- Contributing
- Support
๐ Requirements
- PHP 8.1 or higher
- Composer
- Canvas LMS API token
- Extensions:
json
,curl
,mbstring
๐ฆ Installation
โ๏ธ Configuration
API Key Authentication (Simple)
OAuth 2.0 Authentication (User-Based) ๐
Canvas LMS Kit now supports OAuth 2.0 for user-specific authentication with automatic token refresh!
Environment Variable Configuration
Perfect for containerized deployments and 12-factor apps:
Logging Configuration
The SDK supports any PSR-3 compatible logger for comprehensive debugging and monitoring:
Symfony Integration
Advanced Logging Configuration
What Gets Logged:
- โ All API requests and responses (with sensitive data sanitization)
- โ OAuth token operations (refresh, revoke, exchange)
- โ Pagination operations with performance metrics
- โ File upload progress (3-step process)
- โ Rate limit headers and API costs
- โ Error conditions with context
Security: The logging middleware automatically sanitizes sensitive fields like passwords, tokens, and API keys to prevent accidental exposure in logs.
Masquerading (Act As User) ๐
The SDK supports Canvas's masquerading functionality, allowing administrators to perform API operations on behalf of other users. This is essential for administrative operations, support workflows, and testing.
Global Masquerading
Enable masquerading globally for all subsequent API calls:
Context-Specific Masquerading
In multi-tenant environments, masquerading can be set per context:
Security Considerations
- Permissions Required: The authenticated user must have appropriate Canvas permissions to masquerade
- Error Handling: Canvas will return 401/403 errors if permissions are insufficient
- Audit Trail: Consider logging when masquerading is active for compliance
Common Use Cases
Support Operations:
Testing Permission-Based Features:
Batch Operations for Multiple Users:
๐ Pagination
Canvas LMS Kit provides three simple, consistent methods for handling paginated data across all resources:
The Three Methods
When to Use Each Method
Method | Use Case | Memory Usage | API Calls |
---|---|---|---|
get() |
Dashboards, quick views, limited displays | Low (1 page) | 1 |
paginate() |
UI tables, batch processing, when you need metadata | Low (1 page) | 1 per page |
all() |
Complete data export, small datasets (< 1000 items) | High (all data) | As many as needed |
Memory-Safe Processing of Large Datasets
Common Pagination Patterns
Pattern 1: Building a Paginated UI
Pattern 2: Exporting All Data
Pattern 3: Finding Specific Items
PaginationResult Methods
The paginate()
method returns a PaginationResult
object with helpful methods:
Performance Guidelines
Relationship Methods & Large Datasets
Important: Relationship methods on Course/User/Group instances return ALL pages for completeness:
๐ View Complete Pagination Guide for advanced examples and patterns.
๐ก Usage Examples
Working with Courses
Managing Assignments
Working with Modules and Module Items
Working with Current User
Managing Groups
File Uploads
Feature Flags
Conversations (Internal Messaging)
Working with Multi-Context Resources
Some Canvas resources exist in multiple contexts (Account, Course, User, Group). Canvas LMS Kit follows an Account-as-Default convention for consistency:
Multi-Context Resources:
- Rubrics (Account/Course)
- External Tools (Account/Course)
- Calendar Events (Account/Course/User/Group)
- Files (User/Course/Group) - No Account context
- Groups (Account/Course/User)
- Content Migrations (Account/Course/Group/User)
Performance Considerations & Memory Usage
When working with large Canvas instances (universities, enterprise organizations), be mindful of memory usage:
Memory Guidelines:
- Use
get()
for dashboards and quick views (1 API call) - Use
paginate()
for large datasets and UI tables (controlled memory) - Use
all()
only when you need complete data AND know it's reasonably sized - Consider your server's memory limit when using
all()
on production data
Working with Course-Scoped Resources
Some Canvas resources are strictly course-scoped and require setting the course context before use:
Important Notes:
- These APIs will throw an exception if you try to use them without setting the course context first.
- Relationship methods return FIRST PAGE ONLY for performance. To get all items:
Learning Outcomes
Content Migrations
๐ Supported APIs
โ Currently Implemented (45 APIs)
๐ Core Course Management
- โ **Courses** - Full CRUD operations - โ **Modules** - Content organization - โ **Module Items** - Individual content items - โ **Sections** - Course sections - โ **Tabs** - Navigation customization - โ **Pages** - Wiki-style content๐ฅ Users & Enrollment
- โ **Users** - User management with self() pattern support - โ **Enrollments** - Course enrollments - โ **Admins** - Administrative roles - โ **Accounts** - Account management๐ Assessment & Grading
- โ **Assignments** - Assignment management - โ **Quizzes** - Quiz creation and management - โ **Quiz Submissions** - Student attempts - โ **Submissions** - Assignment submissions - โ **Submission Comments** - Feedback - โ **Rubrics** - Grading criteria and assessment - โ **Rubric Associations** - Link rubrics to assignments - โ **Rubric Assessments** - Grade with rubrics - โ **Outcomes** - Learning objectives and competencies - โ **Outcome Groups** - Organize learning outcomes - โ **Outcome Imports** - Import outcome data - โ **Outcome Results** - Track student achievement๐ฌ Communication & Collaboration
- โ **Discussion Topics** - Forums and discussions - โ **Groups** - Student groups and collaboration - โ **Group Categories** - Organize and manage groups - โ **Group Memberships** - Group member management - โ **Conferences** - Web conferencing integration - โ **Conversations** - Internal messaging system - โ **Announcements** - Course announcements extending DiscussionTopics๐ง Tools & Integration
- โ **Files** - File management and uploads - โ **External Tools** - LTI integrations - โ **Module Assignment Overrides** - Custom dates - โ **Calendar Events** - Event management - โ **Appointment Groups** - Scheduling - โ **Progress** - Async operation tracking - โ **Content Migrations** - Import/export course content - โ **Migration Issues** - Handle import problems - โ **Feature Flags** - Manage Canvas feature toggles - โ **Brand Configs** - Theme variables and shared brand configurations - โ **Gradebook History** - Grade change audit trail and submission version tracking - โ **Course Reports** - Asynchronous report generation (grade exports, student data) - โ **Developer Keys** - OAuth API key management for Canvas integrations - โ **Login API** - User authentication credentials and login methods - โ **Analytics** - Learning analytics data (account, course, user level) - โ **Bookmarks** - User bookmark management for Canvas resources - โ **MediaObjects** - Media files and captions/subtitles management๐ Advanced Features
Production-Ready Middleware
Multi-Tenant Support
Pagination Support (Simplified API)
Fluent Interface & Method Chaining
All save()
and delete()
methods return the instance, enabling method chaining:
Relationship Methods
Raw URL Support (Direct API Calls) ๐
Make direct API calls to arbitrary Canvas URLs using the Canvas
facade class:
Features:
- โ Automatic authentication (API key or OAuth)
- โ Response parsing (JSON/non-JSON)
- โ Security validation (domain allowlisting, HTTPS enforcement)
- โ Supports absolute URLs and relative paths
- โ All middleware applied (rate limiting, retries, logging)
Context Management (Account-as-Default)
Canvas LMS Kit uses the Account-as-Default convention for multi-context resources:
Why Account-as-Default?
- โ Consistency across all multi-context resources
- โ Respects Canvas hierarchy (Account โ Course โ User/Group)
- โ Clean separation of concerns
- โ No confusion about which context is being used
๐ Full Context Management Guide
๐งช Testing
Code Quality Tools
- PHP-CS-Fixer: Automatically fixes code to comply with PSR-12 standards
- PHPStan: Static analysis at level 6 for maximum type safety
- PHPUnit: Comprehensive test suite with 2,300+ tests
- Strict Types: All files use
declare(strict_types=1)
for type safety
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines.
Quick Contribution Guide
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Write tests for your changes
- Ensure all tests pass (
composer check
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฌ Support
|
|
|
Resources
- ๐ Wiki Documentation - Comprehensive guides
- ๐ API Reference - Detailed API docs
- ๐ฌ GitHub Discussions - Community forum
- ๐ง Email: [email protected]
โญ Show Your Support
If you find this project helpful, please consider giving it a star on GitHub! It helps others discover the project and motivates continued development.
All versions of canvas-lms-kit with dependencies
ext-json Version *
ext-curl Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.3
psr/log Version ^3.0