Installation
Get Canvas Framework up and running in just a few minutes with Composer.
System Requirements
- PHP 8.2 or higher
- Composer for dependency management
- Web server (Apache, Nginx, or PHP built-in server)
Create a New Project
Create a new Canvas application using the skeleton project:
composer create-project quellabs/canvas-skeleton my-canvas-app
cd my-canvas-app
Add Canvas to Existing Project
To add Canvas to an existing project, install it via Composer:
composer require quellabs/canvas
Create a `public` folder and copy essential files
To create a public folder with the main driver file index.php and a .htaccess file, run:
composer require quellabs/canvas-apache
Configuration file
Optionally add the canvas config file. Place it in the /config directory:
<?php
// Base source directory relative to config folder
$srcDir = dirname(__DIR__) . '/src';
return [
// True to put the framework in debug mode; this mainly affects caching
'debug_mode' => true,
// Template engine
'public_directory' => 'public',
// Template engine
'template_engine' => 'smarty',
// Path to controller classes
'controller_directory' => $srcDir . DIRECTORY_SEPARATOR . 'Controllers',
// Path to error handlers
'error_handler_directory' => $srcDir . DIRECTORY_SEPARATOR . 'Errors',
// Path to aspect-oriented programming files
'aspect_directory' => $srcDir . DIRECTORY_SEPARATOR . 'Aspects',
// Path to database entities files
'entity_path' => $srcDir . DIRECTORY_SEPARATOR . 'Entities',
// Path to signal listeners
'signal_listeners_path' => $srcDir . DIRECTORY_SEPARATOR . 'Listeners',
// Whether to match routes with trailing slashes
'match_trailing_slashes' => false
];
Project Structure
Canvas follows a conventional directory structure:
my-canvas-app/
├── public/
│ ├── index.php # Application entry point
│ └── .htaccess # Apache configuration with URL rewriting
├── src/
│ ├── Controllers/ # Your controllers
│ ├── Entities/ # Entity classes
│ └── Aspects/ # AOP aspects
├── templates/ # Templates (usually Smarty)
├── storage/ # Runtime files
├── migrations/ # Database migrations
├── config/ # Configuration files
└── vendor/ # Composer dependencies