First steps with GraphQL in Laravel Framework - Part One


GraphQL1 is one of the recent major technologies introduced by Facebook in the React ecosystem. Essentially it is a declarative approach for querying data from a backend.

“React is changing the way we build complex client-side UI applications. Flux rethinks the flow of data through applications. GraphQL is changing the way we fetch our data from the server.”

In a nutshell, GraphQL is challenging REST. The key concept is that the client is the only component of an …

Read More
JavaScript Quiz Answers Explained


JavaScript is notoriously a simple programming language, but let’s be honest: it sucks!

Don’t get me wrong! I love programming in JavaScript, it gives extraordinary freedom in building things that runs everywhere, but at the cost that is so easy to write bad code. The reason falls back to its winding history, starting from its creation in 10 days by Brendan Eich. Wikipedia has an exhaustive entry on the subject, so I suggest you to check it.

Nevertheless after 20 …

Read More
Laravel 5 Cron Jobs on shared hosting


The Laravel documentation covers all the information you need to configure Cron Jobs on your hosting machine. Some years ago we were required to define an entry on the server for each task we needed to schedule. Now with Laravel we can simply define a single entry that interacts with the Schedule object, which will take care to run the tasks that are due.

The only Cron entry needed on the server, is the following

* * * * * php /path/to/artisan schedule:run >> /dev/null 2 …
Read More
Five Programming Problems


Recently I stumbled upon this blog post on ShiftedUp. The writer briefly explains that he encountered many cases of job applications for Software Engineer positions, made by people who actually have no idea of what programming means.

Then he proposes 5 coding problems to solve in less than one hour, using whatever programming language you are comfortable with. So I decided to take the challenge! The language used is JavaScript, but the examples can be written easily in any other …

Read More
Insert a record in database for each result from a SQL query

Just a little trick

Nothing too much elaborate! This is a little useful trick to insert a record in a table for each result from a SQL query. It comes in handy for example when you have to manually populate intermediate table, in case of a many-to-many relationship.

Let’s take a basic example. Suppose that you have a list of products in your database and these products are related to a number of online stores.

SELECT * FROM product

| ID | Name   |
|  1 …
Read More
Log Route calls in Laravel using Middleware


Sometimes when developing a new site or application in Laravel you need to log exactly the route calls in order to track bugs and errors. This operation is straightforward.

First, let’s create a new Middleware

php artisan make:middleware LogRouteMiddleware

Then edit the handle function like the following:


public function handle($request, Closure $next)

    return $next($request);

The fullUrl method logs the full …

Read More