From CodeIgniter to Laravel Part 1 - Prologue

From CodeIgniter to Laravel Part 1 - Prologue


So I wrote a web application back in 2010 - which in itself was a rewrite from a fantastic spaghetti code PHP application (talking about - that is still used today and will be in the foreseeable future. The application at hand consists of three parts:

  • Customer application
  • Administrative panel
  • Trainer application

In short, customers can order different workshops (articles) created in the administration panel that then have trainers assigned to them. It would not be feasible to write everything new from scratch since features get added all the time (thanks, COVID), making keeping feature parity double the work. So I've decided to start with the trainer application, which is mostly (like 99.9%) feature complete. Also, it does not change as much as the two other parts.

It's a relatively colossal PHP legacy application written (according to phploc 7.0.2: 97504 lines of code) in CodeIgniter 3 (started at 2), which runs on PHP7.3 (started at 5.3) using Bootstrap 3.3.* and absolutely no tests whatsoever. Having no tests is terrible for the app's quality and even worse for the developer's confidence when adding new features.

The CodeIgniter framework

CodeIgniter was the first time I've encountered the Model-View-Controller (MVC) design pattern, not knowing what a design pattern is. So I've tried my best to separate concerns, not always being successful; the Administration controller class had almost over 6.000 (!) lines of code before I started breaking it down into smaller controllers into RESTful and single-action controllers, respectively. Also, who would have known that having more files doesn't cost anything?

Not mobile-friendly

Trainers can use the app on mobile, but the experience is subpar. Back in 2010, there weren't that many mobile websites, and to be honest, it was never a requirement. However, a decade later, things have changed a lot, so mobile-first will be the route to go.

Did I tell you about deployment?

There are no fancy bells and whistles, just a simple (s)FTP-Server on a shared host. Deploying like it's 1999. Deployment is going to change for the better.


The database runs on a reasonably standard MySQL having 75 tables with about 360.000 rows of data. But not having any form of migrations doesn't help keep local, development and production stages in sync. Also, I made questionable design choices in the past (many-to-many relations where one-to-many would've been enough). So the data structure will not change, except adding created_at and updated_at timestamps to use Laravel's built-in Eloquent methods for setting those columns upon creating/updating models. At least I've had the brilliant idea to go with UTF-8 instead of ISO-8859-whaddayaknow (

No tests

As I've mentioned before, there aren't any tests. However, ever since watching Test-driven Laravel by Adam Wathan, I'm hooked on TDD. And Laravel with PHPUnit makes it super-easy, making sure your code does what it is supposed to do. Having automated tests in place also ensures that you didn't break anything that worked before by accident.


CodeIgniter doesn't have a templating engine, so that's that. Working with Laravel Blade and coming back to writing something like this:

<?php if ($condition): ?>
<?php else: ?>
<?php endif; ?>

<?php foreach ($lines as $line): ?>
		<td><?php $line->value; ?></td>
<?php endforeach; ?>

It gets tedious pretty fast.


Well, yes, of course, the application uses jQuery. And jQuery UI. Because ten years ago, there weren't that many alternatives (remember or MooTools?). Today, there's React, Vue, Svelte, Angular, to name a few. I've been a web developer for 20+ years now, and if I can say one thing for sure, your philosophy to live by should be YAGNI: You Ain't Gonna Need It. Adding technical debt and overhead before writing a single line of code will not help you in the long run. Most applications do not need a fancy Kubernetes cluster running dockerized everything; sometimes, a simple LAMP- or LEMP-stack server is enough. Alpine.js and Livewire are more than capable of building suitable UI components.


It's dangerous to go alone, so I've asked a fellow developer to help me on this journey. Together we'll make an excellent, test-driven, mobile-first web application running on PHP 8, Laravel, Livewire, Alpine.js, TailwindCSS. We've set the time frame to around six months, so in Summer 2022, we will finish the new trainer application.