'How to install GD Library? Laravel at AWS Lambda with Bref
When using Intervention\Image in laravel on lambda The following error has occurred. By the way, it works in the local environment.
I have to add gd.
[2021-08-17 10:37:18] DEV.ERROR: GD Library extension not available with this PHP installation. {"exception":"[object] (Intervention\Image\Exception\NotSupportedException(code: 0): GD Library extension not available with this PHP installation. at /var/task/vendor/intervention/image/src/Intervention/Image/Gd/Driver.php:19)
What I looked up
Deployment method
We are deploying to lambda using the sls command.
sls deploy --stage dev
Based on the investigation, the following is implemented
composer require bref/extra-php-extensions
Added below serverless.yml
plugins:
    - ./vendor/bref/bref
    - ./vendor/bref/extra-php-extensions #add
functions:
    # This function runs the Laravel website/API
    web:
        image:
            name: laravel
        events:
            -   httpApi: '*'
    # This function lets us run artisan commands in Lambda
    artisan:
        handler: artisan
        timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-80}
            - ${bref:layer.console}
            - ${bref-extra:gd-php-80} #add
Even if the above settings are added and deployed, they are not updated. .. why?
enviroment
- Laravel Framework 8.33.1
 - PHP 7.4.3
 - bref
 - serverless
 
I'm sorry if English is strange.
Solution 1:[1]
Put the layers into web "tag".
plugins:
    - ./vendor/bref/bref
    - ./vendor/bref/extra-php-extensions #add
functions:
    # This function runs the Laravel website/API
    web:
        image:
            name: laravel
        layers:
            - ${bref-extra:gd-php-80} #add
        events:
            -   httpApi: '*'
    # This function lets us run artisan commands in Lambda
    artisan:
        handler: artisan
        timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-80}
            - ${bref:layer.console}
Then add the folder php/conf.d inside put a file with extension .ini. For example php.ini. In it just put:
extension=gd
    					Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | Camilo | 
