Skip to content

Update OCI8 layer for Bref 3#647

Merged
mnapoli merged 1 commit intobrefphp:masterfrom
ss10sb:oci8-v3
Mar 9, 2026
Merged

Update OCI8 layer for Bref 3#647
mnapoli merged 1 commit intobrefphp:masterfrom
ss10sb:oci8-v3

Conversation

@ss10sb
Copy link
Contributor

@ss10sb ss10sb commented Mar 6, 2026

Update the OCI8 layer for version 3. A lot of this is thanks to the work of @alraben and the previous maintainer's version. It is currently only compatible with PHP 8.3+.

It has been tested against a live app using arn:aws:lambda:us-west-2:873528684822:layer:php-84:16 as the base layer. Hopefully there aren't any sneaky dependency issues that I missed.

ARG OL_VERSION=8
ARG IC_VERSION=21
# Oracle Instant Client image
FROM public.ecr.aws/docker/library/oraclelinux:$OL_VERSION AS oracle_base
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested the layer? Here the library is installed in an image that is not the one used in AWS Lambda, there's high risk the library is incompatible when running in Lambda.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did. I created a custom layer and ran it with arn:aws:lambda:us-west-2:873528684822:layer:php-84:16. It connected and queried an Oracle database happily. I even tried it with the v2 layer (al.2) - which failed due to an incompatible lib. I totally get if you're not comfortable approving this PR. It could certainly have some sneaky issues. I'm happy to keep using my custom layer until you or the previous maintainer can get around to updating it :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — I tested this in a real AWS Lambda environment and it works correctly.

I built a custom OCI8 layer and deployed it in a Lambda running Bref 3 on Amazon Linux 2023. The function successfully connects and executes queries against an Oracle database using oci_connect().

The Dockerfile is parameterized, so the same build works for PHP 8.3+ (8.3 / 8.4 / 8.5) by simply changing the PHP_VERSION build argument.

Example:

docker build
–build-arg PHP_VERSION=83
–build-arg BREF_VERSION=v3
-t oci8-layer .

Then the /opt directory is extracted and packaged as a Lambda layer.

After attaching the layer to the Lambda function and setting:

LD_LIBRARY_PATH=/opt/lib

OCI8 works correctly in the Lambda runtime.

One important thing I discovered during testing:

Oracle Instant Client 23.26 caused PHP-FPM crashes in Lambda.

The extension loaded correctly (it appeared in phpinfo()), but any call to oci_connect() triggered:

Error communicating with PHP-FPM to read the HTTP response.
Bref will restart PHP-FPM now.

CloudWatch logs showed the PHP-FPM worker exiting.

After switching to Oracle Instant Client 21.12, the problem disappeared and OCI8 worked perfectly.

Another small issue was that the runtime layer must include libociicus.so, otherwise OCI8 fails with:

OCIEnvNlsCreate() failed

Once that library was added to the layer, everything worked as expected.

This setup also works correctly with Laravel using the yajra/laravel-oci8 package, so applications using that driver can run without problems on Lambda.

So yes — this solution has been tested in a real Lambda environment and works correctly with:
• Bref 3
• Amazon Linux 2023
• PHP 8.3+ (8.3 / 8.4 / 8.5)
• Oracle Instant Client 21.12

@mnapoli mnapoli merged commit 9e49cb9 into brefphp:master Mar 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants