我有这样的路线:
Route::get('cron_job/{param1}/{param2?}', function($param1 = NULL, $param2 = NULL)
{
//do something here;
echo "Im'm here with param". $param1;
});
我使用这条路线进行cron作业,它运行正常。
但是现在,我想用另一个路径来尝试用循环测试它,像这样:
Route::get('test_cron_job', function()
{
do {
$param = 1;
// here I just want to call http://my_app.local/cron_job/$param1
$param++;
} while ($param <10)
});
怎么做?在cronjob中我使用:
links -dump http://my_app.local/cron_job/$param1
但是如何在route.php中的另一条路径内调用它来测试呢?
试试吧:
Route::get('test_cron_job', function()
{
do {
$param1 = 1;
// here I just want to call http://my_app.local/cron_job/$param1
redirect('/cron_job/'.$param1);
$param++;
} while ($param <10)
});
你可以使用file_get_content(url);
$file = file_get_contents("http://www.example.com/{$param1}", false, $context);