PHP code example of tomwalder / polyfill-appengine-google-cloud-tasks

1. Go to this page and download the library: Download tomwalder/polyfill-appengine-google-cloud-tasks library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tomwalder / polyfill-appengine-google-cloud-tasks example snippets


use google\appengine\api\taskqueue\PushTask;
use google\appengine\api\taskqueue\PushQueue;

$task1 = new PushTask('/someUrl');
$task2 = new PushTask('/someOtherUrl');
$queue = new PushQueue();
$queue->addTasks([$task1, $task2]);

use google\appengine\api\taskqueue\PushTask;

$task1 = new PushTask('/someUrl');
$task1->add();

CloudTasksQueue::initLocation('europe-west2');

putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');

$obj_client = new CloudTasksClient([
   'keyFilePath' => '/path/to/keyfile.json'
]);
CloudTasksQueue::initClient($obj_client);

CloudTasksQueue::initHttpTarget('https://my-awesome-project-hvdgury43f-ew.a.run.app');

CloudTasksQueue::initProject('my-awesome-project');

CloudTasksQueue::ensureQueues(true);