0

I have a PHP script which performs a SQL query. This works well, the data, formatted as a table, show up. Then I want to parse a cron expression, to find out when the last three executions of a specific cronjob were planned.

This is the code:

for($i = 0; $i <= 2; $i ++)
{
    $date = $return[$i]->cronexpression;
    var_dump($date);
    $cron = Cron\CronExpression::factory($date);
    $cron->isDue();
    $real_date = $cron->getPreviousRunDate(null, $i)->format('Y-m-d H:i:s');
    $return[$i]->cronexpression = $real_date;
}

The manual for the parser can be found here: https://packagist.org/packages/dragonmantank/cron-expression .

When I add the for-loop and this bit of code:

require_once '/vendor/autoload.php';

the table doesn't show up, an empty page is displayed. The var_dump is not shown in the console. How can I make this work? Thanks!


Edit:

I found the error.log. It had two messages:

First: [php7:warn] [pid 4916:tid 1544] [client 127.0.0.1:54056] PHP Warning: require_once(/vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\cronjob-overview\api\get_cronjob.php on line 7, referer: http://localhost:8080/overview

Second: [php7:error] [pid 4916:tid 1544] [client 127.0.0.1:54056] PHP Fatal error: require_once(): Failed opening required '/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\cronjob-overview\api\get_cronjob.php on line 7, referer: http://localhost:8080/overview

Line 7 is this: require_once '../vendor/autoload.php';
I checked the vendor folder´, the autoload.php is there. I am puzzled, what else could be the reason?

Peter
  • 35
  • 1
  • 9
  • What do you mean by "not working"? Do you get any errors? Add [error reporting](//php.net/manual/function.error-reporting.php) at the top of your file(s): `ini_set("display_errors", 1); error_reporting(E_ALL);` and tell us what you get. – Goodbye StackExchange Mar 06 '19 at 14:31
  • See [How do I get php errors to display](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) and [PHP WSOD](https://stackoverflow.com/questions/1475297/phps-white-screen-of-death) – Xatenev Mar 06 '19 at 14:31
  • Thanks to you both for the quick reply! @FrankerZ: with "not working" I mean that the table doesn't show up. I don't get any errors. I added the lines, but I get no error message. – Peter Mar 06 '19 at 14:49
  • @Xatenev: I checked the php.ini, display_errors is on. – Peter Mar 06 '19 at 14:49
  • A blank page means specifically it's disabled. ADD it to the top. Ensure it's being output. – Goodbye StackExchange Mar 06 '19 at 14:53
  • @Peter Are you sure you are editing the correct php.ini? Check `phpinfo();` - it will tell you the path to the used php.ini and the values of `display_errors` and `error_reporting` – Xatenev Mar 06 '19 at 14:57
  • I edited my question to answer your questions. – Peter Mar 07 '19 at 08:56
  • I am a step further: I moved the vendor folder to where a config file is pointing, and the error went away ... – Peter Mar 07 '19 at 10:22

0 Answers0