doctrine/doctrine1
Legacy Doctrine 1 ORM for PHP, providing ActiveRecord and Data Mapper features with a SQL abstraction layer, migrations, schema tools, and powerful query building. Useful for maintaining older Doctrine 1 applications or studying the classic ORM API.
Check Compatibility Since this package is abandoned and explicitly advises upgrading to Doctrine 2, verify if your project can migrate. If not, avoid using this package entirely.
Installation (Legacy Context Only)
composer require doctrine/doctrine1:^1.2.4
Basic Configuration
models/ directory for Doctrine entities.application/config/doctrine.php (if present) or manually set up:
Doctrine_Core::configure(array(
'model_path' => app_path('models'),
'connection' => array(
'driver' => 'pdo_mysql',
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'dsn' => env('DB_DATABASE'),
),
));
First Use Case: Querying Data
// Load a model (e.g., User.php)
$user = Doctrine_Core::getTable('User')->find(1);
echo $user->name;
Define Entities
// app/models/User.php
class User extends Doctrine_Record {
public function setTableDefinition() {
$this->table['name'] = 'users';
$this->hasColumn('name', 'varchar', 255);
$this->hasColumn('email', 'varchar', 255);
}
}
Create Records
$user = new User();
$user->name = 'John Doe';
$user->email = 'john@example.com';
$user->save();
Query Builder
// Find all active users
$users = Doctrine_Core::getTable('User')
->createQuery('u')
->where('u.is_active = ?', 1)
->execute();
Relationships
// One-to-Many (User → Posts)
class User extends Doctrine_Record {
public function setUp() {
$this->hasMany('Post as Posts');
}
}
doctrine/orm or Eloquent instead.Security Risks
Performance Quirks
$user = Doctrine_Core::getTable('User')
->find(1, array('alias' => 'u', 'with' => 'Posts'));
fetchArray() or fetchAll().Configuration Overrides
// config/app.php
'providers' => [
// Remove 'Illuminate\Database\DatabaseServiceProvider',
];
Deprecated Features
Doctrine_Query is outdated; prefer Doctrine_Query_Abstract or raw SQL.Doctrine_Core::getTable('User')->getConnection()->setLogging(true);
Doctrine_Core::getTable('User')->getConnection()->getLog();
Doctrine_Record methods (e.g., preSave(), postDelete()).Doctrine_Record_Plugin) for reusable logic.$users = DB::table('users')
->where('id', $user->id)
->pluck('name');
How can I help you explore Laravel packages today?