Eric Barnes

Eric Barnes

Where I put stuff that I find interesting.
May 8th 2012

Testing Backbone with Jasmine and Sinon

A nice three part tutorial for behavior-driven testing BackBone applications with Jasmine, Sinon, and Jasmine jQuery plugin.

May 2nd 2012

Making Backbone Applications Realtime With Pusher

This seems to be a pretty handy piece of JavaScript to integrate Backbone with Pusher.

May 1st 2012

Laravel Book - Code Happy

Dayle Rees who is an active Laravel community member and an all around nice guy has written a great resource guide for Laravel. This book is designed to take you from the first steps of getting started with the framework, through the structure, and then covers each major section of the framework. If you want to get up to speed quickly with Laravel I think this book should be high on your priority list.

The problem with most books for technology is that they quickly become out of date. Dayle decided to use LeanPub to self-publish this book. So that means if errors are found he can fix it and you get a new version. If v4 comes out Dayle can update the book with any new features or remove deprecated items and the book remains up to date. Every time a change happens with the book you get an email and can download the new version. So awesome. :)

At the time of this writing the book currently has 22 chapters:

  1. Getting Started
  2. Project Structure
  3. Using Controllers
  4. Routes With Closures
  5. Links and URLs
  6. Forms
  7. Handling Input
  8. Validation
  9. The Untold Story
  10. Migrations
  11. Fluent Query Builder
  12. Eloquent ORM
  13. Events
  14. Blade Templates
  15. Authentication
  16. The Blog Tutorial
  17. Unit Testing
  18. Caching
  19. Autoloading Classes
  20. Configuration
  21. The IoC Container
  22. Encryption

Now go buy Code Happy and make your life easy.

April 30th 2012

20 Awesome Resources for Twitter Bootstrap Lovers

If you use bootstrap for your design structure be sure and check out this resource list. They listed a few items I haven’t seen before.

April 28th 2012

Not all licenses are created equal

As you are all are hopefully aware there are huge differences the exact “freedoms” allowed by the various open source licenses. I find that many younger developers have a natural affinity to the GPL, because they seem to feel its important to prevent someone from just taking their code, building upon it and not releasing their changes under an open source license when they distribute. Maybe with enough experience you start to realize that it happens close to never that a proprietary fork of an open source project ends up outpacing the original project. So why bother regulating this? It just makes legitimate business uses harder and in the grand scheme of things, I don’t worry about this. People who prefer to go proprietary are likely not in the state of mind yet where I would want to work with them anyway.

That is the first paragraph from the article and I feel it sums up nicely a lot of my thoughts on the issue. I am sure back in the 70’s or 80’s when the software freedom was started it was a different battle field. But today I feel like it is just a huge hinderance. But the much bigger problem is people blindly choosing licenses that they don’t fully understand.

Laravel Blade

March 25th 2012

Blade is the simple template/theme system built into Laravel and up until this point it has been very basic. It supported most of the simple things such as variables {{ $var }}, @if @else, @section, and finally a thing called @yield.

Because of the simplicity of it on a new project I thought we would need something more advanced and went with Twig. Twig had more features and was more powerful but it also didn’t really fit into my workflow. The biggest problem was working with Eloquent results and twig doesn’t like calling results like this:

foreach (Book::with('author')->get() as $book)
{
    echo $book->author->name;
}

I asked Taylor about it and he did a few changes to get that working but then I had troubles with other calls. So it just felt like it was more of a fight than what it was worth. After discussing this, last week Taylor and Shawn McCool really made Blade awesome. First Shawn recommended a “render_each” method. Which is an excellent feature in my opinion. It works my including a looped view:

<ul>
    {{ render_each('categories.list', $categories, 'cat') }}
</ul>

// categories/list.blade.php
<li>{{ $cat->name }}</li>

As you can see that is a big time saver. But it doesn’t stop there. Now Blade can have layouts inheritance and several other really useful goodies:

@layout('layouts.common')

@section('content')

    <p>My content</p>

@endsection

Then inside layouts.common:

<html>
<head>
    <title>Test</title>
</head>
<body>
    @yield('content')
</body>
</html>

This is just some of the basics of the new features and it does a lot more. Although I don’t consider it a full replacement for Twig it has 90% or more of the features I wanted to use. The biggest missing feature (depending on your needs) is that Blade still just parses as php. So it can call things that are not assigned and doesn’t prevent you from using php code in your views. Personally I like that feature but if you are really wanting to limit what people can do in the views then this may not be ideal. So use what is best for the task at hand.

For a video overview of what is coming please watch this:

March 14th 2012

Learning from source code

Shawn McCool over at Big Name posted a video discussing learning from the source code. This video is Laravel specific but it does hit on the point that the docs are almost never 100% complete compared to the actual source code. So by spending that extra few minutes reading that you can understand exactly what is going on.

While you are on his site check out his other great Laravel videos.

Laravel Sublime Text Snippets

March 9th 2012

If you use the Laravel php framework and Sublime Text I highly recommend you try the new snippets Dayle Rees created. It really does speed up your development and is really nice.

You can get all the code from GitHub: https://github.com/laravel/sublime-snippets