dimanche 6 mars 2016

Laravel custom helper - undefined index SERVER_NAME

In Laravel 5.1, I created a custom helper file: custom.php which I load in composer.json:

"autoload": {
    "files": [
        "app/Helpers/custom.php"
    ]
},

and it contains this method:

function website() {
    return str_replace('dashboard.', '', $_SERVER['SERVER_NAME']);
}

It works as expected, but every time I do php artisan commands, I get a call stack and this message:

Notice: Undefined index: SERVER_NAME in /path/to/custom.php on line 4

Why is this so? The method returns the correct value when run from within my Laravel app.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire