Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine1 Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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.

  2. Installation (Legacy Context Only)

    composer require doctrine/doctrine1:^1.2.4
    
    • Only proceed if maintaining a legacy Laravel 3/4 project (pre-2015).
  3. Basic Configuration

    • Define a models/ directory for Doctrine entities.
    • Configure 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'),
          ),
      ));
      
  4. First Use Case: Querying Data

    // Load a model (e.g., User.php)
    $user = Doctrine_Core::getTable('User')->find(1);
    echo $user->name;
    

Implementation Patterns

Workflow: CRUD Operations

  1. 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);
        }
    }
    
  2. Create Records

    $user = new User();
    $user->name = 'John Doe';
    $user->email = 'john@example.com';
    $user->save();
    
  3. Query Builder

    // Find all active users
    $users = Doctrine_Core::getTable('User')
        ->createQuery('u')
        ->where('u.is_active = ?', 1)
        ->execute();
    
  4. Relationships

    // One-to-Many (User → Posts)
    class User extends Doctrine_Record {
        public function setUp() {
            $this->hasMany('Post as Posts');
        }
    }
    

Integration Tips

  • Laravel 4/5+: Use Doctrine ORM (2.x) via doctrine/orm or Eloquent instead.
  • Legacy Projects: Patch Doctrine 1 for security if critical (e.g., CVE-2014-3669).
  • Migrations: Use raw SQL or a custom migration tool; Doctrine 1 lacks built-in migrations.

Gotchas and Tips

Pitfalls

  1. Security Risks

    • Doctrine 1 is unmaintained and vulnerable to SQL injection if not used carefully.
    • Mitigation: Sanitize inputs manually or upgrade.
  2. Performance Quirks

    • N+1 Problem: Eager-load relationships explicitly:
      $user = Doctrine_Core::getTable('User')
          ->find(1, array('alias' => 'u', 'with' => 'Posts'));
      
    • Lazy Loading: Avoid in loops; use fetchArray() or fetchAll().
  3. Configuration Overrides

    • Doctrine 1 may conflict with Laravel’s service provider system. Disable Laravel’s DB layer if using both:
      // config/app.php
      'providers' => [
          // Remove 'Illuminate\Database\DatabaseServiceProvider',
      ];
      
  4. Deprecated Features

    • Doctrine_Query is outdated; prefer Doctrine_Query_Abstract or raw SQL.

Debugging

  • Enable Logging
    Doctrine_Core::getTable('User')->getConnection()->setLogging(true);
    
  • SQL Dump
    Doctrine_Core::getTable('User')->getConnection()->getLog();
    

Extension Points

  • Custom Behavior: Override Doctrine_Record methods (e.g., preSave(), postDelete()).
  • Plugins: Use legacy Doctrine 1 plugins (e.g., Doctrine_Record_Plugin) for reusable logic.
  • Hybrid Approach: Combine with Laravel’s Query Builder for complex queries:
    $users = DB::table('users')
        ->where('id', $user->id)
        ->pluck('name');
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime