Solving my Lumen errors
I became a new contributor on a project. The project is using Lumen, a micro-framework based on Laravel, is working great in production. To get the project working locally, running git clone was the first step. Fortunately, to get a local server though, you don’t need to worry about Apache configuration. Instead, from the project root directory, you only need to run php artisan serve from the command line. This will start a server with a URL of http://localhost:8000 locally. Since I wasn’t the project creator, most of what’s in the Lumen documentation didn’t apply to me, and felt a little hard to follow.
When all goes well, php artisan serve will start up a local server and display the message “Lumen development server started on http://localhost:8000/” in the terminal.
With my project, it didn’t start. Instead, an exception was thrown. Here’s the error message.
Fatal error: Uncaught exception ‘ReflectionException’ with message ‘Class App\Exceptions\Handler does not exist’ in …
I searched online to find what this error meant. I didn’t find anything with my specific error message. It turned out, some classes were missing. Here’s how I added the missing classes. I created a new temporary project, elsewhere in my filesystem, using php artisan
.
$ composer global require "laravel/lumen-installer=~1.0"
$ lumen new temp-proj
Once I create the temporary project, I copied the {temp-proj}/app/Exceptions/ directory to my {project-root}/app directory,
$ cd {project-root}/app
$ cp -R {temp-proj}/app/Exceptions/ Exceptions/
If you find any other classes are missing, you can repeat this process for those class directories as well.
Useful Tips
When you finally get php artisan serve to run successfully, you should run it in it’s own shell or terminal window. That way you can do continue work in the terminal.
Also, use CTRL+C to stop the artisan server when you’re done. Once the server is started, it’ll log the requests that it receives and any error messages that occur.