Lumen on App Engine


Laravel announced today that they are launching a new PHP framework named Lumen for building API’s and microservices.  It has an emphasis on speed and it is compatible with a subset of Laravel, making for easy migrations to the larger framework.

I wanted to see how easy it would be to run a Lumen app on App Engine, and I fooled around with it a bit. You just do a simple setting in app.yaml to route all of the apps traffic to the default handler for the Lumen app:

application: [your application id]
version: one
runtime: php55
api_version: 1


- url: /.*
  script: /[path_to_lumen_folder]/public/index.php

With that I got a basic instance running. I did run into one problem though.  The logger tried to write to disk, which is a no-no for App Engine. If this happens you will get an error like this:

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "[Path to your lumen app]/storage/logs/lumen.log" could not be opened

One little configuration tweak got it working though. In [path to your lumen app ]vendor/laravel/lumen-framework/src/Application.php, you have to tweak the logger a bit.

First you add a reference to the right library:

use MonologHandlerSyslogHandler;

And then replace the function getMonologHandler() with this:

protected function getMonologHandler()
return new SyslogHandler('intranet', 'user', Logger::DEBUG, false, LOG_PID);

This advice was taken from the guide for Laravel on PHP for App Engine.

All in all, it is a relatively quick little framework, and having using App Engine to scale out the services it provides seems like a no-brainer.

All code shown here is licensed under Apache 2. For more details find the original source on Github.

5 thoughts on “Lumen on App Engine

  1. Thanks for the article!
    I recently tried to set up Laravel 5 on GAE and I had major issues with page load times.
    I did a lot of optimizations and the best page load time I could get from a fresh L5 without database and any filesystem request was 200-500ms!
    I just tried setting up Lumen on GAE. It was MUCH easier to set up and page load time is mostly between 100-130ms. Amazing!


    1. Essentially, yes. App Engine command line and GUI tools have a “deploy” option that handles uploading all of the files.


      1. Got it, thanks. What do you think about the instance hours free quota? It may easy to exceed it? And talking about numbers, how many users could be doing operations simultaneity (light writing operations and fetching some data), without getting the quota exceeded? Lumen helps in those aspects?

        Thank you again!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s