So in this article I’m going to explain how to test every route in a laravel application. I usually name all the routes in my application, so essentially, every route in my application has some sort of sanity test.

One thing that annoys me about homestead is that I have to switch to the Homestead directory in order to use vagrant.

vagrant up

Instead I made a little helper that takes out a step. Now I can just run

homestead up

Laravel 5 gives us a nifty little command to change our application’s namespace. Out of the box the default namespace is App. To change it, we simply run:

php artisan app:name Horsefly

However, once you register your app namespace, how do you get it later? Laravel doesn’t save it in config(‘’) or anything like that.

Today I fiddled around generating docs for a company package. There are a lot of doc generators out there, here are a few and their examples:

I played around with some of these. I like the approach of annotated source code but sometimes it is more useful to have api documentation. Annotated source code is cool because you can follow along line by line and really uncover the guts of a library. When I’m looking for public methods I don’t want to have to sift through annotated source code.

How easy is it to search for files with laravel? Using Symfony’s Finder class it is really, really easy!

Say I wanted to recursively search a directory for all the files with fish in the name, over 100KB in size and had some text: ‘awesome’ inside of the file. That would be a tough one with just native php but never to fear, Fabien Potencier is here. Oh and I forgot to mention, I only want files that have been modified since yesterday. Oh and can you sort those by name for me? Thanks.

After 2 years of using Laravel, I’d never been a huge fan of blade. When I first met Taylor Otwell at Genghis grill, I probably insulted him by saying:

“I hate blade” - me to Taylor Otwell

ETags PHONE HOME?! No. So what are ETags? Wikipedia has this to say:

The ETag or entity tag is part of HTTP, the protocol for the World Wide Web. It is one of several mechanisms that HTTP provides for web cache validation, and which allows a client to make conditional requests. This allows caches to be more efficient, and saves bandwidth, as a web server does not need to send a full response if the content has not changed. ETags can also be used for optimistic concurrency control as a way to help prevent simultaneous updates of a resource from overwriting each other.

Let’s say you are running a report for the user. You generate some temporary file to give to the user and now you have this zombie pdf file sitting out there in your /tmp directory. How do you clean it up? Why not do it directly after you serve to the user? Here are a couple of options. The first option just cleans up the file after the application has served the response.

Route::get('get-file', function()
$filename = storage_path() . '/testing.txt';

App::finish(function($request, $response) use ($filename)

return Response::download($filename);

After kicking the boot around for a while I finally decided to re-factor the asset pipeline. The functionality is all in all the same but the code is easier on the eyes. However, I did bring in a lot of new features.

  • Config allows you to control caching interface
  • Config allows you to control directives
  • Config allows you to control which environments are concatenated
  • Config allows you to control mime types so you can combine javascripts and stylesheets in a single folder
  • Use a sprockets parser and generator to create the Rails-style asset pipeline functionality
  • Use relative paths in the manifest files
  • Use Laravel event listener to alter the configuration of the pipeline after package boot/start up
  • Use caching to speed up local development when using a lot of pre-processors (i.e. coffee, less, sass)
  • Use assets:generate to create static files in public/assets directory.
  • Completely customize the javascript_include_tag, stylesheet_link_tag composers
  • Completely customize the AssetController class