How To Resolve Route Not Found Lumen In Subdirectory

Didik Tri Susanto
Teknomuslim
Published in
1 min readFeb 27, 2017
image source: https://laravel-news.com

Lumen is a micro framework built by Taylor Otwell. It has same core with Laravel but only loads basic package so you can build a high speed service or API.

I am rarely using Lumen for my projects because I still need Laravel as my current stack. Lately I am building a microservice for task scheduling, then I choose Lumen because I don’t need all stacks in Laravel. Just building API and generating queue jobs to publish some data to other provider.

Subdirectory Problem

I deployed Lumen as subdirectory, so APIs endpoint is like http://domain.com/lumen/

Then RouteNotFoundException displayed. I was confused a little bit, and this is my steps to resolved this issue:

  • Tried to enable mod rewrite apache and it was already enabled. (Exception is not resolved)
  • Set AllowOverride All in apache config. (Exception is not resolved)
  • Make sure Lumen’s storage directory is writable. (Exception is not resolved).
  • I Googled around and finally found this article, http://www.simonfoster.co.uk/running-lumen-from-a-sub-directory/
  • Add Request::capture() inside run method. So basically, my index.php is like this.
  • Hit API and Lumen is working.

Finally, happy Monday!

--

--

Didik Tri Susanto
Teknomuslim

Proud to be Moslem | Introvert | Backend Engineer | Laravel Developer