August 2017

Development Decisions: Choosing an open-source framework

Most developers understand the importance of using frameworks, but making the long-term commitment to choose one can be a daunting task. It seems like every week a new framework is released, promising to ease the troubles of developers everywhere.

Aside from considering the architecture and security each framework offers, when deciding which to use there are some less obvious, but important areas that should be considered:

  1. Is it easy to learn, and does it have great documentation?
  2. Does it decrease development time by requiring less code?
  3. Is the creator actively developing it, and is it generating interest amongst the open source community?

Great documentation is the most important step when choosing a framework. Since it was introduced in 2011, Laravel rose to the top of the PHP frameworks in a very short time, partly because of its thorough documentation. Taylor Ottwell, Laravel’s creator, spends a great deal of time asking the community what can be documented better or what is missing, and actively works to improve the framework.

Another big reason to choose a framework is that it can drastically decrease the amount of time in your builds. It takes care of the boilerplate code that is common amongst almost every build, so you can get back to making great applications. Vue JS, a relative newcomer to the front-end javascript scene, built their framework with this core principle: “Do more with less code.” Not only did it succeed in that aspect, but because it is plain javascript at its core, and not a derivative of it like Angular or React, it lessens development time with its small learning curve.

Laravel’s Eloquent ORM is a perfect example of how frameworks can help accomplish a basic task, like user creation, with significantly less code. Here’s an example written in PHP without a framework, demonstrating how we might go about creating a user if they don’t already exist.

$sql = "SELECT * FROM users WHERE email = :email";
$q->execute([:email' => '']);
$user = $q->fetchAll(PDO::FETCH_ASSOC);

if (isset($user['id'])) {
 $sql = "INSERT INTO users
    (name, email, password)
    VALUES(:name, :email, :password)";
 $q->execute([':name' => 'Rob Fonseca', ':email' => '', ':password' => 'my encrypted password']);

Now this is how we can accomplish the same action in Laravel:

$user = User::firstOrCreate([‘name’ => ‘Rob Fonseca’, ‘email’ => ‘’, ‘password’ => ‘my encrypted password’]);

The firstOrCreate() method automatically handles the task of looking up to see if the user exists and either returning that user or creating a new record. Not only is the syntax much more readable, but there are 83% less lines written to accomplish the same task.

While great documentation and decreasing time are huge factors in the choice, none of it matters if the framework is going out of favor with developers – either because it is slow to add new features or fix critical flaws. Finding out who designed the framework, researching how active they are in fixing issues on Github, and what they see in the pipeline for new features can be a great indicator of the sustainability of the community.

No framework is one-size fits all. Each of them have their positives and shortcomings, and most of the top frameworks will get the job done in similar ways. The key is to examine the focus areas above to find which ones can suit the needs and enhance the talents of your team.

Don’t miss what’s next. Sign up for connectD newsletters.