Symfony Panther crontab usage

16 Views Asked by At

When using the functionality via cron, the file completes its work before receiving the result from ChromeClient (even with the wait functionality). What to do in this case? How can I make cron wait for the results from the browser to complete?

function example($url) {
    $client = Client::createChromeClient(null, null, [
         'port' => $availablePort,
    ]);
        
    $client->request('GET', $url);
    $client->waitForElementToContain('body', '{"status":"success"', 10);
    $data = $client->getCrawler()->filter('body')->text();
        
    $client->quit();

    return $data;
}

Cron function example:

<?php
$data = [];

foreach($lala as $url) {
    $data[] = example($url);
}

print_r($data); // empty result instantly without waiting

If i use crontab file directly on client - all works fine.

0

There are 0 best solutions below