3. Laravel on Google App Engine

Setup Laravel

  • Setup or use an existing Laravel project. Run php artisan serve to test it.
  • Set het storage pad in bootstrap/app.php:

    $app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));

Setup Deployments

  • Setup a app.yaml file selecting a PHP version (7.4 in this case) like the ones below. It is possible to setup multiple YAML-files and trigger de deployment per file to a specified version:

    # app.staging.yaml
    # 
    # GOOGLE APP ENGINE DEPLOYMENT FILE
    # gcloud app deploy app.staging.yaml -v staging --no-promote
    #
    
    runtime: php74
    
    # Put production environment variables here.
    env_variables:
    
        # Applicaton key
        APP_KEY: base64:dZt3l...
    
        # Storage path
        APP_STORAGE: /tmp
        VIEW_COMPILED_PATH: /tmp
        SESSION_DRIVER: cookie
        CACHE_DRIVER: file
        FILESYSTEM_DRIVER: public
    
        APP_ENV: staging
    
        #MYSQL SETTINGS
        DB_DATABASE: apply_api_staging
        DB_USERNAME: root
        DB_PASSWORD: ******
        DB_SOCKET: "/cloudsql/de-maastricht-studie-api:europe-west3:apply-api"
        DB_CONNECTION: mysql
    
    handlers:
        # All URLs beginning with /stylesheets are treated as paths to
        # static files in the stylesheets/ directory.
        - url: /favicon\.ico
          static_files: public/favicon.ico
          upload: public/favicon\.ico
    
        - url: /logo-small\.png
          static_files: public/logo-small.png
          upload: public/logo-small\.png
    
        - url: /vendor
          static_dir: public/vendor
    
        - url: /images
          static_dir: public/images
    # app.yaml
    # 
    # GOOGLE APP ENGINE DEPLOYMENT FILE
    # gcloud app deploy app.yaml -v production --promote
    #
    
    runtime: php74
    
    # Put production environment variables here.
    env_variables:
    
        # Applicaton key
        APP_KEY: base64:dZt3l...
    
        # Storage path
        APP_STORAGE: /tmp
        VIEW_COMPILED_PATH: /tmp
        SESSION_DRIVER: cookie
        CACHE_DRIVER: file
        FILESYSTEM_DRIVER: public
    
        APP_ENV: production
    
        #MYSQL SETTINGS
        DB_DATABASE: apply_api
        DB_USERNAME: root
        DB_PASSWORD: ******
        DB_SOCKET: "/cloudsql/de-maastricht-studie-api:europe-west3:apply-api"
        DB_CONNECTION: mysql
    
    handlers:
        # All URLs beginning with /stylesheets are treated as paths to
        # static files in the stylesheets/ directory.
        - url: /favicon\.ico
          static_files: public/favicon.ico
          upload: public/favicon\.ico
    
        - url: /logo-small\.png
          static_files: public/logo-small.png
          upload: public/logo-small\.png
    
        - url: /vendor
          static_dir: public/vendor
    
        - url: /images
          static_dir: public/images