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?