Search code examples
google-app-enginegoogle-app-engine-php

Running Google App Engine as PHP Command Line?


I currently have a small Google App Engine project written in PHP. On a traditional web server, I would simply invoke this particular code via command line (e.g., php whatever.php). I'd like to set this up with cron.yaml to just run every hour or so without invoking a HTTP request if possible. How would you go about doing this?


Solution

  • You can do this by adding a handler url that points to your script as follows:

    In your app.yaml it would look like this:

    handlers:
    - url: /mycron
      script: cron.php
      login: admin
    

    The login parameter will only allow execution of the endpoint by Google system accounts or something like that so you enpoint won't be publicly accessible.

    More information in the below link

    ref: https://cloud.google.com/appengine/docs/standard/php/config/cron#securing_urls_for_cron