mercredi 23 mars 2016

Check if an environmental variable is set in Laravel 5

I'm using laravel facebook sdk

in the /config/laravel-facebook-sdk.php

I current have

'facebook_config' => [
    'app_id' => env('FACEBOOK_APP_ID'),
    'app_secret' => env('FACEBOOK_APP_SECRET'),
    ...
],

My page work fine, if I provide these fields in the .env file.

FACEBOOK_APP_ID=**********
FACEBOOK_APP_SECRET=*****************************

My goal is prevent my page to crash even I haven't provided those yet.

So I've tried adding a ternary check, but that doesn't to work.

'facebook_config' => [
    'app_id' => env('FACEBOOK_APP_ID')? env('FACEBOOK_APP_ID') : '',
    'app_secret' => env('FACEBOOK_APP_SECRET')? env('FACEBOOK_APP_SECRET') : '',
    ...
],


I kept getting

enter image description here

Any hints / suggestions on that will be much appreciated !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire