Weave 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

Bolt Laravel Package

stefanak-michal/bolt

Low-level PHP library for communicating with graph databases over TCP using the Bolt protocol. Works with Neo4j, Memgraph, Amazon Neptune and others, supports Bolt up to version 6, requires PHP 8.1+ with mbstring, and needs sockets or openssl only for certain connection classes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Release Delta (v7.4.0 → v7.5.0) — Why This Assessment Changed

  • Observability is now first-class: the logging mechanism was refactored to a PSR-3 compatible logger. This removes the single largest "custom wrapper" cost identified previously — the driver can now be wired directly into Laravel's Log facade / Monolog channels with no shim.
  • Bookmarks + a new query method (PR #200) unlock causal consistency (read-your-own-writes) across Neo4j cluster members — directly relevant to the previously flagged connection-pooling and read-replica concerns.
  • Bolt 6.1 / PackStream update (PR #202) raises the supported protocol ceiling. The prior assumption of "defaults to 4.3–6.0" must be revised; the protocol-compatibility matrix now needs re-validation against the target database version.
  • Deprecation: setting the PackStream version directly is now deprecated (Bolt 6.1 couples PackStream to the Bolt version). Any in-house wrapper that called the PackStream setter must be audited.
  • Non-breaking constructor change: AProtocol constructor arguments changed, but this is explicitly safe only for consumers that obtain the protocol via Bolt::build. Any Laravel service provider or test double that instantiated AProtocol directly is impacted.
  • autoload.php removed: Composer-only installation now required. Non-Composer or manual-vendored deployments break.
  • UnsupportedType structure added: unknown protocol types now surface as an explicit value rather than an ambiguous failure — a real reduction in silent-corruption risk for heterogeneous graph stores.
  • Vendor breadth widened: new integration test workflows for ArcadeDB, TuGraph, Grafeo, plus a workflow that checks new Bolt versions. This materially improves the package's release-cadence and multi-vendor credibility.
  • Auth surface touched: an error-handler test was reworked to use the basic authentication scheme, indicating auth negotiation behaviour is in flux — worth pinning in the PoC.

Architecture Fit

  • Graph Database Integration: The package provides a low-level Bolt protocol driver for PHP, enabling direct TCP socket communication with graph databases (Neo4j, Memgraph, Amazon Neptune, ArcadeDB, TuGraph, etc.). This aligns well with Laravel applications requiring high-performance graph queries (recommendation engines, fraud detection, knowledge graphs).
  • Protocol Agnosticism: Supports Bolt through 6.1, with version negotiation. The 6.1 addition is coupled to a specific PackStream version, which simplifies the contract but means the package now tracks database releases, not just protocol numbers.
  • Pipeline Support: Pipelined run/pull chaining reduces latency for batch operations — useful for Laravel queue jobs and bulk ingestion.
  • Causal Consistency: New bookmark support allows a Laravel request to write via one connection and read via another with read-your-own-writes guarantees. This is the architectural unlock for safely placing the driver behind an HTTP/gRPC service or a clustered graph deployment.

Integration Feasibility

  • Laravel Compatibility: PHP ≥8.1 (Laravel 9+); requires sockets/openssl extensions. Composer is now mandatory (internal autoload.php removed) — irrelevant for standard Laravel apps, blocking for hand-vendored setups.
  • PSR-3 Logging (new): The driver's logger can be satisfied by Laravel's container-resolved Psr\Log\LoggerInterface, so Bolt traffic lands in existing Monolog channels and stack drivers. This collapses a previously bespoke integration into a container binding.
  • ORM/Query Builder Synergy: Still integrates via a custom connection/GraphQueryBuilder; unchanged in principle:
    class GraphQueryBuilder {
        public function run(string $cypher, array $params): array {
            $bolt = (new Bolt(new Socket('127.0.0.1', 7687)))
                ->setProtocolVersions(6.1)
                ->setLogger(app(\Psr\Log\LoggerInterface::class)) // v7.5.0+
                ->build();
            return $bolt->run($cypher, $params)->pullAll()->getResponses();
        }
    }
    
  • Event-Driven Workflows: Unchanged fit with Laravel events and queues.

Technical Risk

  • Low-Level Complexity — reduced but not removed. Manual Bolt message handling (hello/logon/run/pull) still requires boilerplate; the Client helper or a Laravel service wrapper remains the mitigation.
  • Connection Management — no built-in pooling. Risk: socket exhaustion under load. Mitigation: custom pool or DatabaseManager abstraction. Bookmarks partially mitigate the correctness half of this problem (consistent reads), but not the resource-exhaustion half.
  • Version-Drift Risk — elevated. Bolt 6.1 ties PackStream to the Bolt version, and the project ships a workflow specifically to catch new Bolt versions. This is a healthy signal, but it means upgrades are now coordinated events: bump the package and re-validate against the database's Bolt 6.1 support. Pin the driver version in composer.json and treat minor bumps as review-required.
  • Deprecation Debt — any wrapper calling the PackStream version setter will emit deprecation notices and lose forward compatibility. Audit before upgrading.
  • Direct AProtocol Construction — the constructor signature change is safe only via Bolt::build. Mock-based unit tests that instantiate AProtocol directly will fail at upgrade time.
  • Auth Behaviour in Flux — the basic-auth error-handler rework means authentication negotiation is actively changing. Pin the auth scheme in the PoC and add a regression test.
  • Error Handling — responses are still binary; validate with Response::isSuccess(). The new UnsupportedType structure reduces (but does not eliminate) silent mis-typing across heterogeneous backends.
  • Cypher Parameter Safety — unchanged: raw Cypher carries injection risk; enforce parameterised queries via code review or a query-builder wrapper.

Key Questions

  1. Use Case Clarity: Real-time traversals or batch analytics? Does the graph store replace or supplement MySQL/PostgreSQL?
  2. Protocol Pinning: Which Bolt version does the target database negotiate, and does it support 6.1? If the DB is older, the 6.1 default must be explicitly overridden.
  3. Consistency Model: Will the application read from the same node it wrote to, or across a cluster? Bookmarks now make cross-node consistency tractable — is it in scope?
  4. Upgrade Discipline: Do we pin the driver and schedule re-validation per minor release, given the version-coupled PackStream change?
  5. Team Expertise: Graph/Cypher/Bolt experience and budget for a custom wrapper; the PSR-3 logging change reduces but does not eliminate this cost.

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Logging (new): Bind Psr\Log\LoggerInterface to the driver; route Bolt diagnostics through config/logging.php channels. Replaces the previous custom debug-mode approach.
    • Database Layer: Custom connection driver extending Illuminate\Database\Connectors\ConnectionFactory, or service-container binding.
    • Query Builder: Extend Illuminate\Database\Query\Builder for Cypher.
    • Scout: Graph-backed search alternative to Elasticsearch.
    • Events/Jobs: Event sourcing and async graph updates via Bolt.
    • Cluster reads (new): Use bookmarks to enforce read-your-own-writes when graph access is split across pooled connections or replicas.
  • Microservices: Deploy graph access as a separate Laravel API consumed over HTTP/gRPC.
  • Hybrid Architecture: Laravel for CRUD + graph store for traversals.

Migration Path

  1. Proof of Concept (PoC):
    • Replace one complex query ("friends of friends") with Cypher via Bolt.
    • Explicitly validate against the target Bolt version, including 6.1 if available; if not, pin to the supported version.
    • Wire the PSR-3 logger to a Laravel channel so failures are visible from day one.
  2. Incremental Adoption:
    • Phase 1: Bolt as a secondary data source (cache results in Redis).
    • Phase 2: Migrate read-heavy graph operations.
    • Phase 3: Migrate write-heavy relationship updates; introduce bookmarks at the point where reads and writes diverge across nodes.
  3. Tooling: Artisan commands for SQL→graph sync, now with PSR-3 structured logging for audit trails:
    $bolt = app(BoltService::class);
    foreach (User::all() as $user) {
        $bolt->run("CREATE (u:User {id: \$id, name: \$name})", [
            'id' => $user->id,
            'name' => $user->name,
        ]);
    }
    

Compatibility

  • Protocol Versions: Bolt 4.x–6.1. Default behaviour now targets a 6.1-capable stack; older databases must be pinned explicitly via setProtocolVersions(...).
  • PackStream: No longer independently configurable — the setter is deprecated; treat PackStream as derived from Bolt version.
  • Installation: Composer required; the removed autoload.php breaks manual vendoring.
  • Internal APIs: Obtain protocols only via Bolt::build; do not construct AProtocol directly.
  • Authentication: Basic, Bearer, Kerberos — basic-auth path was touched in this release; pin and regression-test it.
  • Data Types: PHP types map to PackStream; unknown types now surface as UnsupportedType, which should be handled explicitly rather than cast.
  • Transactions: begin/commit/rollback supported; bookmarks complement transactions for cross-connection consistency.

Sequencing

  1. Infrastructure Setup: Deploy Neo4j/Memgraph/ArcadeDB (Docker/K8s); open Bolt port 7687; confirm the server's Bolt version.
  2. Dependency Upgrade: Bump to v7.5.0, pin the version, audit for PackStream setter usage and direct AProtocol instantiation, and confirm Composer-only install.
  3. Laravel Configuration:
    'connections' => [
        'neo4j' => [
            'driver' => 'bolt',
            'host' => env('NEO4J_HOST', '127.0.0.1'),
            'port' => env('NEO4J_PORT', 7687),
            'username' => env('NEO4J_USER'),
            'password' => env('NEO4J_PASSWORD'),
            'protocol_versions' => [6.1],   // lower if the server requires it
            'log_channel' => env('NEO4J_LOG_CHANNEL', 'stack'),
        ],
    ],
    
  4. Driver Development: Extend Illuminate\Database\Connection; inject the PSR-3 logger; wrap bookmark capture/consume.
    class BoltConnection extends Connection {
        public function run($query, $bindings = [], $useReadPdo = true) {
            $bolt = (new Bolt(new Socket($this->config['host'], $this->config['port'])))
                ->setProtocolVersions($this->config['protocol_versions'])
                ->setLogger(app(\Psr\Log\LoggerInterface::class))
                ->build();
            return $bolt->run($query, $bindings)->pullAll()->getResponses();
        }
    }
    
  5. Testing: Unit-test Cypher via DatabaseMigrations; add a Bolt-version compatibility test for the pinned server; load-test with Laravel Dusk/Artillery.

Operational Impact

Maintenance

  • Release Cadence: The project now runs automated Bolt-version checks and multi-vendor integration tests. Expect frequent minors; pin and review, since version coupling means a minor bump can change wire behaviour.
  • Dependency Updates: Track Bolt/PackStream changes (6.1 and beyond); keep sockets/openssl/mbstring enabled in php.ini.
  • Deprecation Burndown: Remove any use of the PackStream version setter and any direct AProtocol construction this quarter.
  • Schema Management: Laravel Migrations for SQL + Cypher scripts for graph schema (Neo4j Browser, Artisan commands).
  • Logging: Use PSR-3 → Laravel log channels (replaces Bolt::$debug); log query execution time and connection lifecycle events.

Support

  • Troubleshooting: Verify firewall, service status, port 7687; validate Cypher in Neo4j Bloom; profile with Neo4j Profiler or DB::enableQueryLog().
  • Upgrade Triage Playbook (new): Because the constructor and PackStream surfaces changed, define a standard checklist — pin version, run compatibility test, verify auth regression test, confirm Composer autoload.
  • Documentation: Maintain a runbook for common Bolt errors (e.g., INVALID_SIGNATURE) and documented Cypher traversal patterns.
  • Vendor Support Matrix: Record which backends (Neo4j, Memgraph, ArcadeDB, TuGraph, Grafeo) are validated for the pinned driver version — the package's own test matrix is a useful starting point but is not a guarantee of production readiness.

Scaling

  • Horizontal Scaling: Neo4j Causal Clustering with Bolt-aware failover; bookmarks are now the mechanism for consistent reads across cluster members, replacing ad-hoc "read from primary" workarounds.
  • Connection Pooling: Still no built-in pool — the primary unresolved scaling risk. Mitigations, in order of preference:
    1. Run graph access behind a dedicated Laravel service with long-lived workers (Octane/Swoole) that hold a bounded pool of Bolt connections.
    2. Implement a custom pool bound as a singleton in the service container, with health checks and reconnect-on-failure.
    3. Cap concurrency via queue worker limits so Bolt sockets stay within the database's max_connections. Note that pooling and bookmarks must be designed together: a pooled read connection must consume the bookmark produced by the write connection, or consistency guarantees silently lapse.
  • Async Processing: Route heavy graph writes through Laravel queues to smooth peak load.

Failure Modes

  • Socket exhaustion under high concurrency (no pool).
  • Silent protocol mismatch after a driver minor bump against an older server — mitigated by pinning + the compatibility test.
  • Upgrade breakage from direct AProtocol use or PackStream setter calls — mitigated by the audit checklist.
  • Auth negotiation regression given the basic-scheme rework — mitigated by an explicit regression test.
  • Bookmark leakage if write-bookmarks are not propagated to subsequent reads, yielding stale reads that look correct in low-traffic testing.

Ramp-Up

  • Lower than the prior assessment: PSR-3 logging removes the custom observability build, and expanded vendor test coverage plus documented client helpers shorten time-to-first-query.
  • Remaining learning curve is Cypher and graph data modelling, not the driver itself.
  • Estimate: ~1–2 days for a Laravel engineer to reach a working PoC; ~1–2 weeks to production-grade with pooling, bookmark propagation, and the upgrade playbook. Budget training on Cypher and cluster consistency semantics, not on Bolt plumbing.
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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core