NOTE: This repository is part of Google Cloud PHP. Any
support requests, bug reports, or development contributions should be directed to
that project.
Installation
To begin, install the preferred dependency manager for PHP, Composer.
Now install this component:
$ composer require google/cloud-tasks
This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods)
please see our gRPC installation guide.
Authentication
Please see our Authentication guide for more information
on authenticating your client. Once authenticated, you'll be ready to start making requests.
Sample
require_once __DIR__ . '/vendor/autoload.php';
use Google\Cloud\Tasks\V2\CloudTasksClient;
use Google\Cloud\Tasks\V2\Queue;
$client = new CloudTasksClient();
$project = 'example-project';
$location = 'us-central1';
$queue = uniqid('example-queue-');
$queueName = $client::queueName($project, $location, $queue);
// Create a queue
$locationName = $client::locationName($project, $location);
$queue = new Queue([
'name' => $queueName
]);
$queue->setName($queueName);
$client->createQueue($locationName, $queue);
echo "$queueName created." . PHP_EOL;
// List queues
echo 'Listing the queues' . PHP_EOL;
$resp = $client->listQueues($locationName);
foreach ($resp->iterateAllElements() as $q) {
echo $q->getName() . PHP_EOL;
}
// Delete the queue
$client->deleteQueue($queueName);
Debugging
Please see our Debugging guide
for more information about the debugging tools.
Version
This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in
any minor or patch releases. We will address issues and requests with the highest priority.
Removal of pull queue
The past version (V2beta2) supported pull queues, but we removed the
pull queue support from V2/V2beta3. For more details, read
our documentation
about the removal.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [2.0.2 (latest)](/php/docs/reference/cloud-tasks/latest)\n- [2.0.1](/php/docs/reference/cloud-tasks/2.0.1)\n- [1.15.2](/php/docs/reference/cloud-tasks/1.15.2)\n- [1.14.6](/php/docs/reference/cloud-tasks/1.14.6)\n- [1.13.2](/php/docs/reference/cloud-tasks/1.13.2)\n- [1.12.2](/php/docs/reference/cloud-tasks/1.12.2)\n- [1.11.11](/php/docs/reference/cloud-tasks/1.11.11) \n\nGoogle Cloud Tasks for PHP\n==========================\n\n\u003e Idiomatic PHP client for Google Cloud Tasks.\n\n[](https://packagist.org/packages/google/cloud-tasks) [](https://packagist.org/packages/google/cloud-tasks)\n\n**NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any\nsupport requests, bug reports, or development contributions should be directed to\nthat project.\n\n### Installation\n\nTo begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/).\n\nNow install this component: \n\n $ composer require google/cloud-tasks\n\nThis component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods)\nplease see our [gRPC installation guide](https://cloud.google.com/php/grpc).\n\n### Authentication\n\nPlease see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information\non authenticating your client. Once authenticated, you'll be ready to start making requests.\n\n### Sample\n\n require_once __DIR__ . '/vendor/autoload.php';\n\n use Google\\Cloud\\Tasks\\V2\\CloudTasksClient;\n use Google\\Cloud\\Tasks\\V2\\Queue;\n\n $client = new CloudTasksClient();\n\n $project = 'example-project';\n $location = 'us-central1';\n $queue = uniqid('example-queue-');\n $queueName = $client::queueName($project, $location, $queue);\n\n // Create a queue\n $locationName = $client::locationName($project, $location);\n $queue = new Queue([\n 'name' =\u003e $queueName\n ]);\n $queue-\u003esetName($queueName);\n $client-\u003ecreateQueue($locationName, $queue);\n\n echo \"$queueName created.\" . PHP_EOL;\n\n // List queues\n echo 'Listing the queues' . PHP_EOL;\n $resp = $client-\u003elistQueues($locationName);\n foreach ($resp-\u003eiterateAllElements() as $q) {\n echo $q-\u003egetName() . PHP_EOL;\n }\n\n // Delete the queue\n $client-\u003edeleteQueue($queueName);\n\n### Debugging\n\nPlease see our [Debugging guide](https://github.com/googleapis/google-cloud-php/blob/main/DEBUG.md)\nfor more information about the debugging tools.\n\n### Version\n\nThis component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in\nany minor or patch releases. We will address issues and requests with the highest priority.\n\n### Removal of pull queue\n\nThe past version (V2beta2) supported pull queues, but we removed the\npull queue support from V2/V2beta3. For more details, read\n[our documentation](https://cloud.google.com/tasks/docs/alpha-to-beta#pull)\nabout the removal."]]