My first (real) foray into Laravel

I’ve long had a distaste for Laravel, as those who know me well are aware, but it seems it might have been unwarranted.

My exposure to it thus far has been Laravel 3/4 projects that have been thrust upon me in one way or another, projects with little to no common structure, and it has driven me bonkers. I’ve truly hated it, and voiced my annoyance at it many a time. Yet it turns out I might have been, to a point, wrong in doing so, and I will happily admit to it.

The projects I’ve been given have been creations of Frankenstein, they’ve had the Laravel part gutted and put together in unintended ways, adding to the developer debt of it all, I did not know this. I did not know Laravel, and thus the issues I came about mentally turned into Laravel being the problem from my side of it all.

I may mention comparrisons/likes/dislikes between Laravel and WordPress, because I do primarely work with WordPress, it’s what I enjoy.

I’ll give Laravel a fair chance

So here I am, I grabbed Laravel 5.3 (I like shiny new things), and set forth to create a project. I need a project, I can’t just learn for the sake of learning, I need there to be a purpose behind the knowledge.

The structure makes sense, the approach to many elements are sane and I can see why things are as they are and why they go where they go. I’m moving slowly, learning as I go, complaining to friends in the Laravel world when things dont’ work as I want them to (or when it’s just being dumb, sorry Amanda!), but I’m making headway.

Some annoyances are not just in my mind

I do have some gripes with Laravel, coming from WordPress I am (possibly) spoiled by the backwards compatibility dedication we put into everything, granted I see this as less of a problem of being spoiled, and more of a dedication to the users (and developers), we know that our stuff won’t break if we update.

With most software, you’ll see breaking changes in a major version, while minors are just enhancements and bugfixes. I discovered that this is not true for Laravel.

I followed along to a “learning the basics” guide on Laracast (what I view as the official site for all things Laravel), the guide was made for L5, and the folder structure in Laravel had changed between various versions in the 5.x build, so I had to pause and locate elements my self outside of the guide.

Ok, so we move on, and I find out that there is a class for creating forms and how to do this the Laravel way, you should use the `Form` class, turns out it was removed in 5.2 and now you are expected to type out your forms by hand.

Some of the areas I thuroughly enjoy

CLI with artisan

Laravel ships with `artisan`, a command line tool for building scaffolds and performing various tasks (and it’s very easy to extend and add your own CLI functions for a project).

It feels like a, in some ways, more mature version of WordPress CLI tool, WP-CLI, which also allows for scaffolding plugins, and automating tasks form the command line like updates, new deployments and so forth.

With artisan I can spin up my database changes as migrations are quite nice once you get the hang of them (I’m not happy with mine yet, but at least I have the database tables there to start learning other things).

Blade templating

This took some getting used to, the concept of views and templates are not entirely known to me yet, and replacing PHP code tags with `@` is… weird. I see the value of it, but it does mean you may need to read code to discover the location of the templates you need to change, this is why I like many things with how WordPress does themes, you always know where a file should be depending on the page you are viewing as it has a fixed template hierarchy.

Routes

Oh I do like routes, they help me keep tabs on where URLs should be pointed, the Rewrite API in WordPress is not a great experience if you need to create paths, and I am very impressed with the Laravel route setup. Doubly so when I discovered how you could easily add authentication requirements to individual routes easily and out of the box by just appending the Auth check to the route it self!


That’s as far as I’ve gotten in Laravel, I have some pages, I have some routes and a login system, and I managed to set up a non-default Bootstrap CSS/JS mix to get the ball rolling.

The project is coming along nicely, I’ve not started on the advanced bits for it that require interacting with the API routes for JSON data, but I’m hopeful those will be as easy to work with as the normal HTTP routes and views, but some kind words for Laravel were obviously overdue from my end.

1 thought on “My first (real) foray into Laravel”

  1. It’s weird, my distaste started with Laravel 5.1 The projects I am working on simply refuse to upgrade to 5.3 (even though we’re on 5.5 now?) So small breaking changes build up and the project needs a rewrite in many core things (even the paginator stopped working in 5.3, not sure what the previous developer was doing there, but now we’re stuck) The fact that they break changes in minor releases is a huge deal for companies that intend to keep projects for years. And I advice people to be careful, there are more stable alternatives, the laravel team seems like it is still mostly testing the waters with what they want, and have not yet decided on core things or rules that could be depended on to go unbroken…

Leave a Reply

Your email address will not be published. Required fields are marked *