Get ObjectQuel ORM up and running in just a few minutes with Composer.
Create a new Canvas project, then add ObjectQuel:
composer create-project quellabs/canvas-skeleton my-app
cd my-app
composer require quellabs/canvas-objectquel
When using Canvas, ObjectQuel configuration, entity paths, proxy generation, and CLI tools are all set up automatically. You do need to setup your database credentials.
Add ObjectQuel to an existing project via Composer:
composer require quellabs/objectquel
No additional setup required! ObjectQuel is pre-configured and available through dependency injection:
<?php
namespace App\Controllers;
use Quellabs\Canvas\Controllers\BaseController;
use App\Entity\ProductEntity;
class ProductController extends BaseController {
public function index() {
// EntityManager is automatically available as $this->em
$products = $this->em()->findBy(ProductEntity::class, ['active' => true]);
return $this->render('products/index.tpl', compact('products'));
}
}
For standalone installations, configure ObjectQuel manually:
<?php
use Quellabs\ObjectQuel\Configuration;
use Quellabs\ObjectQuel\EntityManager;
// Create configuration
$config = new Configuration();
$config->setDsn('mysql://user:password@localhost:3306/database');
$config->setEntityNamespace('App\\Entity');
$config->setEntityPath(__DIR__ . '/src/Entity');
// Create EntityManager
$entityManager = new EntityManager($config);
ObjectQuel works well with this directory organization:
my-app/
├── src/
│ └── Entity/ # Your entity classes
├── migrations/ # Database migrations (Phinx)
├── storage/
│ ├── cache/
│ │ ├── proxies/ # Generated proxy classes
│ │ └── metadata/ # Entity metadata cache
└── bin/
└── sculpt # Sculpt CLI tool
Use the Sculpt tool to create entities:
php bin/sculpt make:entity
php bin/sculpt make:entity. Standalone users should explore our Quick Start guide to learn ObjectQuel's query language and entity management.