PHP function using PDO error

Hi guys, I followed this tutorial in order to execute PHP function with AWS Lambda. Seemed to work everything smooth except wehn I tried to run a function using PDO. Below the easy easy code I’m using:

$result = updateArxivar();


function updateArxivar(){
    $db_host = "my_host";
    $db_name = "my_dbname";
    $db_username = getenv("FLY_DATABASE_USER");
    $db_password = getenv("FLY_DATABASE_PW");
        $conn = new PDO('mysql:host='.$db_host.';dbname='.$db_name, $db_username, $db_password);
    }catch(Exception $e){
        fwrite(STDERR, "Hi\n");
        return 0;
    return 1;


If I run it locally with sls invoke local --function hello it works like a charm. When I deploy it and run with sls invoke --function hello it fails with 255 code.
I also updated the dockerfile file in order to force the PDO installation and enabling but no luck: here the gist of dockerfile

Anyone can help me? Thanks!