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

Laravel Oci8 Laravel Package

yajra/laravel-oci8

Oracle database driver for Laravel using the PHP OCI8 extension. Adds an Illuminate/Database-compatible Oracle connection with Laravel version support (5.1+ through 13), plus optional PHPStan/Larastan helpers for OCI8-specific DB methods.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Native Laravel Integration: Extends Illuminate\Database to provide Oracle-specific query grammar, schema builder, and connection handling, ensuring seamless compatibility with Laravel’s Eloquent ORM, Query Builder, and Migrations.
    • Oracle Feature Support: Aligns with Oracle-specific syntax (e.g., JOIN LATERAL, IDENTITY columns, JSON read-only support for 12c+), reducing manual SQL overhead.
    • Version Agnosticism: Supports Oracle 11g–21c with configurable syntax (e.g., binary_ci for case-insensitive LIKE in 12cR2+), enabling backward/forward compatibility.
    • Dynamic Configuration: Allows runtime overrides (e.g., user credentials via callbacks), useful for multi-tenant or role-based Oracle access.
    • Performance Optimizations: Includes connection retry logic, load balancing, and query time logging for debugging.
  • Cons:

    • Limited Write Support for JSON: Only read operations are supported; updates require full JSON document replacement.
    • Schema Constraints: Oracle’s 30-character name limit (configurable to 128 in 12c+) may require prefix management (e.g., DB_PREFIX_SCHEMA).
    • No Native Transactions for Distributed Workloads: Relies on Oracle’s native transaction handling; complex distributed transactions may need manual coordination.

Integration Feasibility

  • High: Designed as a drop-in replacement for Laravel’s default mysql/pgsql drivers. Requires:
    1. OCI8 PHP Extension: Must be installed (pecl install oci8) and enabled in php.ini.
    2. Oracle Client Libraries: Oracle Instant Client or full client tools for connection pooling/load balancing.
    3. Laravel Configuration: Update config/database.php to include the oracle connection array and register the Oci8ServiceProvider (Laravel 5.5+).
  • Compatibility:
    • Laravel 5.1–13.x: Explicit version support; test thoroughly for edge cases (e.g., migrations, caching).
    • Lumen: Requires manual config/database.php setup (no auto-discovery).
    • Third-Party Packages: May need adjustments if they assume MySQL/PostgreSQL-specific features (e.g., softDeletes with deleted_at timestamps).

Technical Risk

  • Critical:
    • OCI8 Dependency: PHP OCI8 extension must match Oracle client version (e.g., 12c+ for JSON support). Mismatches may cause connection errors or syntax failures.
    • Schema Migrations: Oracle’s lack of AUTO_INCREMENT (replaced by IDENTITY or sequences) requires explicit schema definitions. Risks include:
      • Sequence ownership conflicts (fixed in v12.0.0).
      • Trigger-based deleted_at soft deletes may fail if triggers aren’t properly scoped.
    • Case Sensitivity: Oracle defaults to case-sensitive queries; the oracle user provider mitigates this for auth but may affect general queries.
  • Moderate:
    • Performance: Connection pooling (via Oracle’s TNS or middleware) must be configured to avoid overhead.
    • JSON Limitations: Applications relying on JSON updates (e.g., updateOrCreate with nested attributes) will need workarounds.
  • Low:
    • Static Analysis: PHPStan/Larastan support reduces runtime errors during development.

Key Questions

  1. Oracle Environment:
    • What versions of Oracle (11g, 12c, 21c) and OCI8 are deployed? Are there multi-version clusters?
    • Is Oracle Instant Client or full client tools available? Are connection pooling tools (e.g., Oracle RAC) in use?
  2. Schema Design:
    • Are there existing schemas/tables with constraints (e.g., sequences, triggers) that must be preserved?
    • How are primary keys handled (e.g., IDENTITY, sequences, or triggers)?
  3. Application Requirements:
    • Are there JSON-heavy workflows (e.g., document storage)? If so, how will updates be managed?
    • Are there complex transactions spanning multiple Oracle databases or other systems?
  4. Migration Path:
    • What is the current database driver (e.g., MySQL, PostgreSQL)? Are there schema compatibility issues (e.g., ENUM, UUID)?
    • How will testing be structured (e.g., staging Oracle environment, migration scripts)?
  5. Monitoring:
    • Are there existing tools for Oracle performance monitoring (e.g., AWR, OEM)? How will Laravel query logging integrate?
  6. Team Skills:
    • Does the team have experience with Oracle-specific SQL (e.g., JOIN LATERAL, CONNECT BY) and OCI8 quirks?

Integration Approach

Stack Fit

  • Laravel Core: Fully compatible with Eloquent, Query Builder, and Migrations. No architectural changes required beyond configuration.
  • PHP Extensions:
    • OCI8: Mandatory. Must be compiled with Oracle client libraries matching the target Oracle version.
    • PDO_OCI: Optional but recommended for additional compatibility (e.g., with Laravel’s PDO abstraction).
  • Oracle Client:
    • Instant Client: Lightweight option for cloud/containerized deployments.
    • Full Client: Required for advanced features (e.g., RAC, connection pooling).
  • Additional Tools:
    • PHPStan/Larastan: Optional but recommended for static analysis of Oracle-specific queries.
    • Doctrine DBAL: If using Doctrine, may require additional configuration for Oracle dialect.

Migration Path

  1. Preparation:
    • Environment Setup:
      • Install OCI8 (pecl install oci8) and configure php.ini:
        extension=oci8.so
        oci8.connection_class="oci8_connection"
        oci8.default_prefetch=100
        oci8.privileged_connect=0
        
      • Install Oracle Instant Client or full client tools.
    • Dependency Installation:
      composer require yajra/laravel-oci8:^13
      
    • Configuration:
      • Publish the config file:
        php artisan vendor:publish --tag=oracle
        
      • Update config/database.php with the oracle connection array (see README).
      • Register the service provider (Laravel <5.5):
        // config/app.php
        'providers' => [
            Yajra\Oci8\Oci8ServiceProvider::class,
        ],
        
  2. Testing:
    • Unit Tests: Mock Oracle-specific queries using Laravel’s DatabaseMigrations or RefreshDatabase.
    • Integration Tests:
      • Test migrations (e.g., schema creation, IDENTITY columns, sequences).
      • Validate Eloquent models (e.g., softDeletes, JSON attributes).
      • Stress-test connection pooling and retry logic.
    • Performance Benchmarks: Compare query performance against the current driver (e.g., MySQL).
  3. Deployment:
    • Staging: Deploy to a non-production Oracle environment first.
    • Rollout Strategy:
      • Feature flag the Oracle connection for gradual adoption.
      • Monitor connection metrics (e.g., retry counts, query times).
    • Fallback: Ensure graceful degradation (e.g., retry logic, circuit breakers) for connection failures.

Compatibility

  • Laravel Features:
    Feature Compatibility Notes
    Eloquent Full support; use DB::connection('oracle') for queries.
    Migrations Supported, but require Oracle-specific syntax (e.g., IDENTITY for PKs).
    Query Builder Mostly compatible; some methods (e.g., whereRaw) may need Oracle syntax.
    Caching Works with Redis/Memcached; Oracle-specific cache drivers not included.
    Queues No direct impact; uses database connections for table-based queues.
    Scouting Supported if using database-backed search (e.g., Algolia not affected).
    Full-Text Search Added in v12.0.0; requires Oracle 12c+.
    JSON Read-only in 12c+; updates require full document replacement.
    Authentication Oracle user provider mitigates case-sensitivity issues.
  • Third-Party Packages:
    • Packages using raw SQL (e.g., laravel-excel) may need Oracle syntax adjustments.
    • ORM-specific packages (e.g., spatie/laravel-permission) should work if they don’t assume MySQL/PostgreSQL features.

Sequencing

  1. Phase 1: Configuration and Validation
    • Set up Oracle connection in config/database.php.
    • Validate basic queries (e.g., DB::select('SELECT 1 FROM DUAL')).
  2. Phase 2: Schema Migration
    • Adapt existing migrations to Oracle syntax:
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata