Search code examples
phpcodeignitergoogle-app-enginegoogle-cloud-platformgoogle-app-engine-php

How to get a custom php application run from a subdirectory of a CI application on Google App Engine Standard?


I am a bit confused about how to set the app.yaml up in order to get my work done. Previously I had this same codeigniter application running elsewhere with /support sub-directory serving a custom php support desk application. It had no issues. Good ol' apache served it without any issue.

Now I want the same thing to be working on GAE! This is my app.yaml

application: <NAME>
version: 1
runtime: php55
api_version: 1
threadsafe: yes

handlers:

- url: /assets
  static_dir: assets

- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /support/.*
  script: index.php

- url: /.*
  script: index.php
  secure: always

Just to make sure that I get all the files routed correctly after someone provides me a solution. Here's the directory structure for the support desk (It's called hesk)-

enter image description here

I need a solution with wildcards so that /support works flawlessly with the sub-folders & everything.. also need to define static files. as you can see they are scattered all over the place.. not at all convenient but that's how it is! am poor at regex. So please have mercy on me.

Update: I added updated the app.yaml a bit.. now all the php scripts from the support root & 1st level sub-directories work

- url: /support/(.*)/(.*)\.php$
  script: support/\1/\2.php

- url: /support/(.*)\.php$
  script: support/\1.php

But problem is there are a tons of sub-folders in this thing. see this snap below of the support/inc folder. how to handle that? do I have to manually put a url-script pair for all the possible number of sub-dir levels? This is so frustrating!

enter image description here


Solution

  • Solution : Thanks GAEfan.. I kinda mixed n matched from your ideas & finally these are the needed handlers. It's running perfectly now!

    #for all the static files residing at support root or at any other level
    - url: /support/(.*\.(htm$|css$|js$|ico$|jpg$|png$|gif$))$
      static_files: support/\1
      upload: support/.*\.(htm$|css$|js$|ico$|jpg$|png$|gif$)$
      application_readable: true
    
    #for all the php files running at support root or at any other level
    - url: /support/(.+)\.php
      script: support/\1.php
    
    #for using index.php at support root or at any other level
    - url: /support/(.*)
      script: support/\1/index.php
    

    P.S : the handler below can run index.php from any other level but not support root

    - url: /support/(.+)
      script: support/\1/index.php