maximebf / atomik

Micro framework for PHP 5.3+ [UNMAINTAINED]
MIT License
46 stars 18 forks source link

Undefined index: REQUEST_METHOD #44

Open GilDev opened 9 years ago

GilDev commented 9 years ago

Hi, I discovered Atomik few days ago and I LOVE it! Now, I'm making a website for my classmates, just a little web game, and I need to execute a PHP script every midnight. I used ConsoleKit and I'm using Nginx on a Raspberry Pi (Debian). So when I type my command php index.php <command>, it works well, but when I add this line in my cron table: 0 0 * * * php /path/to/index.php <command>, it doesn't works and outputs this error:

PHP Notice: Undefined index: REQUEST_METHOD in /var/www/vendor/atomik/atomik/src/Atomik.php on line 363 PHP Fatal error: Uncaught exception 'AtomikException' with message 'HTTP method not allowed' in /var/www/vendor/atomik/atomik/src/Atomik.php:369 Stack trace:

0 /var/www/vendor/atomik/atomik/src/Atomik.php(209): Atomik::dispatch(NULL)

1 /var/www/index.php(3): Atomik::run()

2 {main}

thrown in /var/www/vendor/atomik/atomik/src/Atomik.php on line 369

So it's saying REQUEST_METHOD isn't defined. That's normal because I'm using php-cli (although I don't understand why it works in shell but not with cron), now is there a solution to make my script not crash? Maybe Atomik could use some sort of error checking with php_sapi_name()? I hope you'll have a solution, thanks!