- How do I install and configure yajra/laravel-oci8 for Laravel 9?
- Run `composer require yajra/laravel-oci8:^13`, then update `config/database.php` to include an `oracle` connection array with your TNS or connection details. For Laravel 5.5+, the package auto-discovers the service provider; for older versions, manually register `Yajra\Oci8\Oci8ServiceProvider`. Ensure the OCI8 PHP extension is installed via PECL (`pecl install oci8`).
- Does yajra/laravel-oci8 support Oracle 12c JSON features like read-only operations?
- Yes, the package supports JSON read operations in Oracle 12c and later. However, write operations (e.g., partial updates) are limited—you must replace the entire JSON document. For complex JSON workflows, consider using Oracle’s native JSON functions in raw SQL or a hybrid approach with stored procedures.
- What Laravel versions are officially supported by yajra/laravel-oci8?
- The package supports Laravel 5.1 through 13.x, with explicit version branches (e.g., `^5.1` for Laravel 5.1, `^13` for Laravel 13). Always install the version matching your Laravel release to avoid compatibility issues. Check the [compatibility table](https://github.com/yajra/laravel-oci8#laravel-version-compatibility) for details.
- How do I handle Oracle sequences (e.g., for auto-incrementing IDs) in Laravel migrations?
- Use the `OracleSchemaBuilder` methods like `bigIncrements()` or `unsignedBigIncrements()` for IDENTITY columns, or manually define sequences with `Schema::create('table', function ($schema) { $schema->id(); $schema->unsignedBigInteger('sequence_column')->as('sequence_name'); })`. For existing tables, ensure sequences are properly referenced in triggers or use `DB::raw()` for custom SQL.
- Can I use yajra/laravel-oci8 with Lumen, and what’s different from Laravel?
- Yes, but Lumen requires manual configuration. Add the package via Composer, then manually register the `oracle` connection in `config/database.php` and ensure the `Oci8ServiceProvider` is included in `bootstrap/app.php`. Unlike Laravel, Lumen lacks auto-discovery, so you must explicitly bind the service provider and facade.
- How do I enable PHPStan/Larastan support for OCI8-specific DB methods?
- Add the package’s extension to your `phpstan.neon` file under the `includes` section: `includes: - vendor/yajra/laravel-oci8/extension.neon`. This enables static analysis for OCI8 methods like `ociExecute()`, `ociFetch()`, and others, reducing runtime errors during development.
- What are the performance considerations for Oracle connections in production?
- Configure Oracle connection pooling (e.g., via Oracle RAC or middleware like `yajra/laravel-oci8-connection-pool`) to avoid overhead. Enable query logging in `config/database.php` for debugging (`'log_queries' => true`), and monitor performance with Oracle tools like AWR or OEM. Avoid frequent reconnects by using persistent connections if supported.
- How do I migrate from MySQL to Oracle using yajra/laravel-oci8?
- Replace MySQL-specific syntax (e.g., `AUTO_INCREMENT`, `ENUM`) with Oracle equivalents: use `IDENTITY` or sequences for auto-increment, `VARCHAR2` for strings, and `TIMESTAMP` for datetime fields. Test migrations thoroughly, especially for soft deletes (Oracle may require triggers) and UUID handling (use `RAW` or `BINARY` types).
- Are there alternatives to yajra/laravel-oci8 for Oracle in Laravel?
- The primary alternative is using the native `pdo_oci` driver with Laravel’s built-in database support, but it lacks Oracle-specific features like JOIN LATERAL or JSON read support. Other options include custom drivers or middleware, but yajra/laravel-oci8 is the most mature, Laravel-integrated solution with Eloquent and Query Builder compatibility.
- How do I debug connection issues with Oracle in Laravel?
- Enable Oracle error logging by setting `'log_queries' => true` in `config/database.php` and check Laravel’s logs for OCI8 errors. Verify the OCI8 extension is enabled in `php.ini` (`extension=oci8.so`) and matches your Oracle client version. Use `oci_connect()` directly in a test script to isolate connection issues, and ensure TNS names or connection strings are correct.