brefphp / extra-php-extensions

Community-maintained extra PHP extensions usable in AWS Lambda with the Bref PHP runtimes.
https://bref.sh/docs/environment/php.html#extra-extensions
213 stars 109 forks source link

`bref-extra:oci8-php-80` doesn't work #323

Open benzoh opened 2 years ago

benzoh commented 2 years ago

Hello. Let me ask you a question. I think I've defined the extension correctly, but it doesn't work.

↓ serverless.yml

functions:
    # This function runs the Laravel website/API
    web:
        handler: public/index.php
        timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
        layers:
            - ${bref:layer.php-74-fpm}
            - ${bref-extra:oci8-php-80}
        events:
            - httpApi: '*'
    # This function lets us run artisan commands in Lambda
    artisan:
        handler: artisan
        timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-74} # PHP
            - ${bref:layer.console} # The "console" layer

plugins:
    # We need to include the Bref plugin
    - ./vendor/bref/bref
    - ./vendor/bref/extra-php-extensions

image

image

image

Do I need to set anything else?

Nyholm commented 2 years ago

It all looks correct. You should probably also add oci8 layer in your artisan function.

What version of bref/extra-php-extensions are you running? Looking at your second screenshot , the "compatible runtimes" seams weird.

Btw, the layer is verified with: https://github.com/brefphp/extra-php-extensions/blob/master/layers/oci8/test.php

benzoh commented 2 years ago

Thank you for your reply.

But I can't increase the runtime version of the extension.

Isn't it necessary to set the parameter here to PROVIDED_AL_2?

image

image

Nyholm commented 2 years ago

FYI: This layer was just updated by @Nemo64

Nemo64 commented 2 years ago

I didn't touch the oci8 layer, I modified the odbc-snowflake layer.

Nyholm commented 2 years ago

Oh, Im confused.

Sorry for the ping

renanwilliam commented 2 years ago

I have the same issue, did you solve it @benzoh ?

benzoh commented 2 years ago

@renanwilliam yes. I solved it by defining the layers myself. Please have a look.

serverless.yml looks like this.

functions:
  app:
    handler: public/index.php
    layers:
      - ${bref:layer.php-80-fpm}
      - arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:layer:lambda-oci8-layer:3
    events:
      - http:
          path: api/hoge
          method: GET
renanwilliam commented 2 years ago

Strange, your Dockerfile looks like the same in the official repo. Is there something relevant different that I was not seeing?

benzoh commented 2 years ago

I think the solution is to publish with the PROVIDED_AL_2 runtime. I published layer with --compatible-runtimes provided.al2 options.

aws lambda publish-layer-version \
    --layer-name lambda-oci8-layer \
    --description "My oci8 layer" \
    --license-info "MIT" \
    --zip-file fileb://dest/oci8.zip \
    --compatible-runtimes provided.al2 \
    --compatible-architectures x86_64
karunakapil commented 1 year ago

I am getting this error : 'user' directive is ignored when FPM is not running as root. Below is my function code in serverless.yml c-api: handler: index.php description: '' timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds) layers: