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

Orient Db Bundle Laravel Package

concept-it/orient-db-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require concept-it/orient-db-bundle dev-master
    

    Add the bundle to app/ApplicationKernel.php:

    new ConceptIt\OrientDbBundle\ConceptItOrientDbBundle(),
    
  2. Configure in config.yml:

    concept_it_orient_db:
        host: "127.0.0.1"
        port: 2480
        user: "root"
        password: "password"
        dbname: "test_db"
        domain_dir: "%kernel.root_dir%/../src/AppBundle/Entity"
        domain_namespace: "AppBundle\Entity"
    
  3. First Use Case: Define an entity (e.g., User) with @Document and @Field annotations (Doctrine ODM style). Persist it via Symfony’s EntityManager:

    $user = new User();
    $user->setName('John Doe');
    $em = $this->get('doctrine.odm.document_manager');
    $em->persist($user);
    $em->flush();
    

Implementation Patterns

Workflows

  1. Entity Management:

    • Use DocumentManager (injected via doctrine.odm.document_manager service) for CRUD operations.
    • Example:
      // Fetch
      $user = $em->find('User', 1);
      
      // Update
      $user->setName('Updated Name');
      $em->flush();
      
      // Delete
      $em->remove($user);
      $em->flush();
      
  2. Querying:

    • Leverage Doctrine ODM’s QueryBuilder or Criteria:
      $query = $em->createQueryBuilder('User')
          ->field('name')->equals('John Doe')->getQuery();
      $users = $query->execute();
      
  3. Event Listeners:

    • Attach listeners to lifecycle events (e.g., prePersist, postRemove) via EventManager:
      $em->getEventManager()->addEventListener(
          'prePersist',
          function ($event) { /* Logic */ }
      );
      
  4. Custom Methods:

    • Extend the bundle’s Persister/Remover by overriding the bundle’s services (e.g., in services.yml):
      services:
          concept_it_orient_db.persister:
              class: AppBundle\Service\CustomPersister
              arguments: ['@doctrine.odm.document_manager']
      

Gotchas and Tips

Pitfalls

  1. Namespace/Directory Mismatch:

    • Ensure domain_dir and domain_namespace in config match your entity paths.
    • Fix: Verify domain_dir points to the root of your Entity directory (e.g., src/AppBundle/Entity).
  2. Connection Issues:

    • OrientDB may reject connections if the database doesn’t exist. Create it manually or use dbname: null to auto-create.
    • Fix: Check host, port, and credentials in config.
  3. Proxy Generation:

    • The proxy_dir must be writable. Defaults to %kernel.root_dir%/cache.
    • Fix: Set proxy_dir to a writable path (e.g., var/cache).
  4. Doctrine ODM Version:

    • The bundle assumes Doctrine ODM v1.x. Conflicts may arise with newer versions.
    • Fix: Pin ODM version in composer.json:
      "doctrine/doctrine-odm": "1.2.*"
      

Debugging

  • Enable Logging: Add to config.yml:

    doctrine_odm:
        logging: true
    

    Check logs in var/logs/doctrine.log.

  • Query Debugging: Use QueryBuilder::getQuery()->getDebugQuery() to inspect generated queries.

Tips

  1. Schema Validation: Validate your schema with:

    php bin/console doctrine:schema:validate
    
  2. Bulk Operations: Use DocumentManager::createBulkOperation() for batch inserts/updates:

    $bulkOp = $em->createBulkOperation();
    $bulkOp->insert($users);
    $bulkOp->execute();
    
  3. Custom Indexes: Define indexes via @Index annotation or YAML:

    # config.yml
    doctrine_odm:
        document_managers:
            default:
                mappings:
                    AppBundle\Entity\User:
                        indexes:
                            - name: "name_idx"
                              fields: ["name"]
    
  4. Transaction Management: Wrap operations in transactions for atomicity:

    $em->beginTransaction();
    try {
        $em->persist($user);
        $em->flush();
        $em->commit();
    } catch (\Exception $e) {
        $em->rollback();
        throw $e;
    }
    
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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui