TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Undefined index: SERVER_NAME
  • Hello, I have a problem when I run a task by the cron similarly to http://forum.kohanaframework.org/discussion/10823/minion-undefined-index-server_name/p1.

    I have kohana 3.3 so I'm using task and not --uri.

    I want call my task in my cron like that: 0 5 * * * php /var/www/mcc-domolive_com/public/index.php --task=backupDomobox

    When I execute the command, I have this error but only in production: ErrorException [ 8 ]: Undefined index: SERVER_NAME ~ APPPATH/config/database.php [ 4 ]

    I really don't know why I have this error. Thank you if you can help me.

  • Because you are using $_SERVER['SERVER_NAME'] in your database configuration file, this value is not available on the command line. Why are you not just using localhost?

  • Use Kohana::$environment to manage configurations. Returning the array in config files on a switch case. It's one of multiple solutions available...

  • thank you for your fast reply. In my database config I already use

    if(Kohana::$environment === Kohana::DEVELOPMENT){ $username = ''; $password = ''; }else{ //environnement prod $username = ''; $password = ''; }

    $_SERVER['SERVER_NAME'] is not write in database.php.

    In my projet, the only time $_SERVER['SERVER_NAME'] is used is in URL.php

    $domain = '';
        // Attempt to use HTTP_HOST and fallback to SERVER_NAME
        $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
         if(isset($_SERVER['HTTP_HOST']) OR isset($_SERVER['SERVER_NAME']))
                  $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];

    Did I need to change it ??

    Thank you so mutch

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion