Laravel: The Ugly Command/Event – Handler System

One distinctive feature Laravel has as part of its optional architecture is the command/event system. Commands are supposed to represent single, discrete pieces of logic that ought to handle a particular job. Events are ways to notify the system that something occurred. Both commands and event employ handlers and commands can implement the SelfHandling interface to combine containing the data of a Command object along with executing the command itself. While the ideas are great, the implementation still is messy and I want to talk about some flaws in the architecture that bluntly stated don’t make a lot of sense to me.

Continue reading “Laravel: The Ugly Command/Event – Handler System”

Laravel 5: .env APP_ENV not Being Read Properly and Quick Fix

So I encountered an issue with Laravel 5 where your APP_ENV in the .env file might not be read. Even if you change it through the Homstead.yaml file, change /etc/php5/fpm/php-fpm.conf, change your .profile file, etc. you still may not see the variable properly reflected when doing something like var_dump($_SERVER) or examining the Application::Environment() function. This post discusses what the issue is and a quick fix for this problem.

Continue reading “Laravel 5: .env APP_ENV not Being Read Properly and Quick Fix”

Laravel: Adding A Default Message to a Select Drop Down with Eloquent

I ran into an issue earlier where I needed to add a default message to a drop down box created through Laravel’s Form builder. The difficulty was that the form select doesn’t allow for a default option. You have to manually add that. If you pre-populate your select with an Eloquent model, you will have to deal with using a Collection. So how can you add to put an item at the head of the list?

Continue reading “Laravel: Adding A Default Message to a Select Drop Down with Eloquent”