PHPackages                             tomwalder/polyfill-appengine-google-cloud-tasks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. tomwalder/polyfill-appengine-google-cloud-tasks

ActiveLibrary[Queues &amp; Workers](/categories/queues)

tomwalder/polyfill-appengine-google-cloud-tasks
===============================================

Allow simple usages of the old Google App Engine native PushTask and PushQueue to work on Cloud Run, other environments using the Google Cloud Tasks API

v0.0.1(5y ago)09Apache-2.0PHPPHP &gt;=5.5.0

Since Oct 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tomwalder/polyfill-appengine-google-cloud-tasks)[ Packagist](https://packagist.org/packages/tomwalder/polyfill-appengine-google-cloud-tasks)[ Docs](https://github.com/tomwalder/php-gds)[ RSS](/packages/tomwalder-polyfill-appengine-google-cloud-tasks/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Polyfill for Google AppEngine Tasks to Google Cloud Tasks API
=============================================================

[](#polyfill-for-google-appengine-tasks-to-google-cloud-tasks-api)

Snazzy title, I know.

If you are doing this on AppEngine PHP 5.5 runtime:

```
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]);
```

or this...

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

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

Then this library will allow that code to work outside of AppEngine, providing a polyfill to using the new Google Cloud Tasks API.

This is a stepping stone to upgrading to [PHP 7 standard runtime](https://cloud.google.com/appengine/docs/standard/php7), [Flexible runtime](https://cloud.google.com/appengine/docs/flexible/php) - or better still, [Cloud Run](https://cloud.google.com/run).

Installation &amp; Setup
------------------------

[](#installation--setup)

Pull in the library with Composer

```
composer require tomwalder/polyfill-appengine-google-cloud-tasks
```

You'll need to configure the location (region) where your Cloud Tasks queues are. Usually do this once in your bootstrap code.

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

### Authentication

[](#authentication)

Your application will need credentials to call the Google Cloud Tasks API. This is usually handled automatically with [Default Credentials](https://github.com/googleapis/google-auth-library-php#application-default-credentials), from GCP instances etc.

If you need to specify the path manually, do something like this...

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

Alternatively, you can configure and inject your own `Google\Cloud\Tasks\V2\CloudTasksClient` as follows. See [Google Client Authentication](https://github.com/googleapis/google-cloud-php/blob/master/AUTHENTICATION.md) for information about authenticating.

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

### Absolute Task URLs (Cloud Run)

[](#absolute-task-urls-cloud-run)

If you are using this library on Cloud Run, or GCP instances (i.e. outside of AppEngine), HTTP push task URLs are no longer relative.

So you will need to set the base HTTP target - all your relative task URLs will be appended to this.

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

Usage
-----

[](#usage)

Essentially, you can do most things using the original Google `PushTask` and `PushQueue` classes. See above for examples.

Further Information
-------------------

[](#further-information)

### Bulk Add

[](#bulk-add)

Google Cloud Tasks does not support bulk-adding, so the polyfill adds each task one after the other for you.

You may notice some increase in latency. Also, in rare cases you may get an error part way through the task enqueueing process. This will result in some, but not all, of your tasks being created.

### Specify Project ID Manually

[](#specify-project-id-manually)

You can specify the Google Project ID manually as follows (we try and extract from the credentials):

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

### Performance

[](#performance)

It is strongly recommended to use the `gRPC` and `Protobuf` extensions to get the best performance out of all Google APIs.

The default is `REST` unless the above are available. The Google Auth stack auto-detects.

Those extensions are available in the Google App Engine PHP 7 runtime and can be enabled in php.ini

- [Google App Engine PHP 7 Runtime Extensions](https://cloud.google.com/appengine/docs/standard/php7/runtime#dynamically_loadable_extensions)
- [PHP gRPC Installation](https://cloud.google.com/php/grpc)

### Force Queues

[](#force-queues)

If you want to be able to use new Queue names without worrying about creating the queues yourself, you can enable as follows:

```
CloudTasksQueue::ensureQueues(true);
```

This will check to see a Queue exists before inserting tasks, and attempt to create it.

This may increase latency and is probably not sensible for production use.

### External Links

[](#external-links)

- [Google Cloud Tasks PHP Client](https://github.com/googleapis/google-cloud-php-tasks)
- [Google Cloud Tasks API](https://cloud.google.com/tasks/docs/reference/rest)
- [Google Client Authentication](https://github.com/googleapis/google-cloud-php/blob/master/AUTHENTICATION.md)

Credits
-------

[](#credits)

Some parts of this code borrowed from:

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2023d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4e0f7bb9ed3cd1e6c7d0068cf6d446cab11ec0908a0328e807a3db9a14f7e63?d=identicon)[tomwalder](/maintainers/tomwalder)

---

Top Contributors

[![tomwalder](https://avatars.githubusercontent.com/u/1258131?v=4)](https://github.com/tomwalder "tomwalder (1 commits)")

---

Tags

googlequeuetaskappenginegoogle cloudgaecloud taskscloud run

### Embed Badge

![Health badge](/badges/tomwalder-polyfill-appengine-google-cloud-tasks/health.svg)

```
[![Health](https://phpackages.com/badges/tomwalder-polyfill-appengine-google-cloud-tasks/health.svg)](https://phpackages.com/packages/tomwalder-polyfill-appengine-google-cloud-tasks)
```

###  Alternatives

[stackkit/laravel-google-cloud-tasks-queue

Google Cloud Tasks queue driver for Laravel

84570.1k](/packages/stackkit-laravel-google-cloud-tasks-queue)[kainxspirits/laravel-pubsub-queue

Queue driver for Google Cloud Pub/Sub.

48381.1k3](/packages/kainxspirits-laravel-pubsub-queue)[tarantool/queue

PHP bindings for Tarantool Queue.

64136.2k4](/packages/tarantool-queue)[orisai/scheduler

Cron job scheduler - with locks, parallelism and more

4037.1k4](/packages/orisai-scheduler)[g4/tasker

Application asynchronous tasks manager and runner, cron-like PHP implementation with ability to run tasks with resolution in seconds

1455.1k](/packages/g4-tasker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
