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

Arangodbbundle Laravel Package

dalv/arangodbbundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Add Repository & Dependencies Update composer.json with the VCS repository and required packages:

    "repositories": [
        { "type": "vcs", "url": "https://github.com/m0ppers/MopArangoDbBundle.git" }
    ],
    "require": {
        "mop/arangodbbundle": "dev-master",
        "triagens/ArangoDb": "2.0.*"
    }
    

    Run composer update.

  2. Enable the Bundle Add to app/AppKernel.php:

    new Mop\ArangoDbBundle\MopArangoDbBundle(),
    
  3. Configure a Connection Define a connection in app/config/config.yml:

    mop_arango_db:
        connections:
            main:
                host: 'localhost'
                port: 8529
                username: 'root'
                password: ''
                database: 'your_db'
    
  4. First Query Inject the ArangoDb\Client service (via triagens/ArangoDb) into a controller/service:

    use ArangoDb\Client;
    
    class MyController extends Controller
    {
        public function index(Client $arangodb)
        {
            $collection = $arangodb->db('your_db')->collection('users');
            $users = $collection->all();
            return $this->render('users/index.html.twig', ['users' => $users]);
        }
    }
    

Implementation Patterns

Connection Management

  • Default Connection: Use default_connection in config to avoid repetitive injection.
  • Dynamic Connections: Pass connection name to services:
    services:
        my.service:
            arguments: ['@mop_arango_db.connection.main']
    
  • Environment-Specific Configs: Override connection settings in config_dev.yml/config_prod.yml.

Query Workflows

  1. Basic CRUD:

    // Create
    $collection->insert(['name' => 'John', 'email' => 'john@example.com']);
    
    // Read
    $users = $collection->byExample(['name' => 'John'])->toArray();
    
    // Update
    $user = $collection->get('user_id');
    $user->name = 'John Doe';
    $user->save();
    
    // Delete
    $collection->remove($user);
    
  2. AQL Queries:

    $query = $arangodb->query('FOR u IN users FILTER u.age > 25 RETURN u');
    $result = $query->execute();
    
  3. Transactions:

    $transaction = $arangodb->beginTransaction();
    try {
        $transaction->collection('users')->insert([...]);
        $transaction->commit();
    } catch (\Exception $e) {
        $transaction->rollback();
    }
    

FOSUser Integration

  • Override User Model: Extend FOS\UserBundle\Model\User and map to ArangoDB collections:
    class ArangoUser extends BaseUser
    {
        public function getId()
        {
            return $this->getKey(); // ArangoDB key
        }
    }
    
  • Repository: Implement FOS\UserBundle\Model\UserInterface and use triagens/ArangoDb methods.

DataCollector

  • Enable in config_dev.yml:
    mop_arango_db:
        data_collector: true
    
  • View queries in Symfony Profiler under "ArangoDB" tab.

Gotchas and Tips

Pitfalls

  1. No Doctrine ORM: This bundle does not provide an ORM like Doctrine. Use raw triagens/ArangoDb methods or a third-party mapper (e.g., ArangoPHP).
  2. FOSUser Quirks:
    • The getId() method must return a string (ArangoDB key), not an integer.
    • Override loadUserByUsername() in your user provider to query ArangoDB directly.
  3. Connection Pooling: The bundle does not manage connection pooling. Reuse the Client instance for efficiency.
  4. Deprecated Methods: triagens/ArangoDb v2.x has breaking changes. Check migration guide.

Debugging

  • Enable Logging:
    mop_arango_db:
        logging: true
    
    Logs appear in app/logs/dev.log.
  • Profiler: Use the DataCollector to inspect slow queries or failed operations.
  • ArangoDB Shell: Test queries directly in ArangoDB shell (arangosh) to isolate issues.

Configuration Quirks

  • Database Creation: The bundle does not create databases/collections. Use migrations or ArangoDB shell:
    arangosh --javascript.execute 'db._createDatabase("your_db")'
    
  • SSL/TLS: Configure in config.yml:
    mop_arango_db:
        connections:
            secure:
                host: 'arangodb.example.com'
                port: 8529
                ssl: true
    

Extension Points

  1. Custom Collections: Create a service to wrap collection logic:
    class UserCollection
    {
        public function __construct(Client $arangodb)
        {
            $this->collection = $arangodb->db('your_db')->collection('users');
        }
    
        public function findByEmail($email)
        {
            return $this->collection->byExample(['email' => $email])->first();
        }
    }
    
  2. Event Listeners: Attach to ArangoDB events (e.g., post-save) via Symfony events.
  3. Custom DataCollector: Extend Mop\ArangoDbBundle\DataCollector\ArangoDbDataCollector for additional metrics.

Performance Tips

  • Batch Operations: Use batch() for bulk inserts/updates:
    $batch = $collection->batch();
    foreach ($users as $user) {
        $batch->insert($user);
    }
    $batch->execute();
    
  • Indexes: Create indexes in ArangoDB for frequently queried fields:
    $collection->ensureIndex(['name' => true]);
    
  • Caching: Cache query results with Symfony’s cache system if queries are static.
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui