Why you shouldn’t set global variables in Base Controller

Laravel Daily posted a new tip today, they explain why you shouldn’t set global variables in Base Controller.

Setting global variables in the base controller works, until you need to add a error page or 404 page. When rendering those pages no controller will ever be hit. So your global variables are not available at that moment.

For the workaround I suggest you take a look at the original article on the Laravel Daily site.

Clean code

Joeri Timmermans, a Symfony developer at Intracto, created a blog post to share some of his personal experiences and tips to write clean code.

Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live. 

He gives tips about writing cleaner code but also explains why it is so important to write clean code.

You can read the full article on the Intracto blog

Laravel 5.3 – Multiple Migration Paths

A awesome new feature coming to Laravel 5.3 is the ability to have multiple migration paths.

This feature comes in handy for all package developers and of course for all package users. Currently when a package wants to use migrations you have to use php artisan migrate to run your own migrations and php artisan migrate –provider”Package\ServiceProvider” to migrate package migration files.

Once Laravel 5.3 has been released you will be able to register multiple migrations paths like this:

$this->loadMigrationsFrom('path/to/migrations/folder');

from in a service provider for example. The end user can now migrate all the migrations while only using php artisan migrate. There is no need to look all the providers up to migrate package migrations.

Passing variables by Value vs. by Reference Visual Explanation

Penjee released a in depth tutorial that explains the difference between passing by value and by reference.

When writing software code, you will spend a lot of time defining, reading and changing variables. Using a variable means you use a descriptive word in your code which holds some information (a number, some text, an object, etc.). This descriptive word is the “title” of the stored information

Create a global .gitignore file

If you are like me you are probably creating a .gitignore file over and over again for every single project. 90% of these .gitignore files are the same, it’s a waste of time creating these files over and over again.

Recently I discovered you can create a global .gitignore file in your .gitconfig file. You can do that by running this command from your terminal:

git config --global core.excludesfile '~/.gitignore_global'

I named my file .gitignore_global just for clarity but you can name it whatever you want.

You can view my personal global .gitignore file on Github.

How to change a file’s last modified date

Ever had the need to change a file’s last modification date? Maybe not and you may be thinking why would you do that?

The reason I wanted to do that was because I was writing a Artisan command to clean up files in a given directory where the modification date was older then one day.

But while writing this command all the files in the directory I wanted to clean up where created and modified the last time on the same day as writing the command. So my script won’t do anything and waiting a day to test it was no option.

If you want to changes the last modification date of a file you can simply run the following command from your terminal:

touch -mt YYYYMMDDhhmm path/to/some/file.jpg

You can also run the command to do this for all the files in a direcotry:

touch -mt YYYYMMDDhhmm path/to/some/dir/*

Blogify the Laravel blog package

Blogify is a blog package made for Laravel,

I created Blogify last year as my final project for school. The reason why I choose to create a package, is that the Laravel community had given so much resources to me and I wanted to give something back.

But why a blog package and not something else?

During my internship I saw that there where a lot of projects that where build a long time ago and suddenly needed a blog and because one of those projects was custom and was based on Laravel we had to write a whole new feature, no big deal but when i asked around it seemed like this happend more often then I expected.

I inspired my whole backend styling on WordPress, it’s the most used blog system in the world so there should be a good reason to do it on a different way.

The WordPress way works and most bloggers know where to search for general things.

But why should u choose Blogify over WordPress? Blogify is designed for developers who love custom build tools and want to integrate a simple blog without using WordPress. And it’s still as easy as managing a WordPress blog.

Eventually I graduated and got nice grades (15/20) for the Blogify package, a very excited Jury and a mention in the Laravel-news newsletter. But then I started working and Blogify did not get the love it needed, unsolved issues, the installation process did not work anymore and 2 new versions of Laravel where released but Blogify was still where it was a year ago.

Last week I started thinking …. the project where I put so much time in was just sitting there somewhere on the web, such a sad story.

So I decided to give Blogify the love it deserved and I migrated the code base over to Laravel 5.2 and solved the issues so users could install it smoothly again.

Make sure to check out this awesome package and spread the word so that I can actually give something back to the community.

Language saver for splash pages using WPML

Recently at work we where implementing a multi language website using WordPress and WPML.
Users would enter the website through a splash page where they have to select their language of choice. While WPML is a very large and popular plugin we couldn’t find a build in feature or plugin to remember the language of choice of the user. So that when they come back to our website they don’t hit the splash page anymore.

After a good google search we came to the conclusion that there wasn’t something out there that could handle our needs so I started developing my first WordPress plugin called: “Language saver for splash pages using WPML”. The plugin is out there for free so feel free to use it.

A big shoutout to These Days Labs for supporting the development of this plugin.

Hello world!

Welcome to my brand new blog. It is a personal experiment to improve my writing and a backlog for problems I tackled in the past. And maybe I can help someone else with any of the solved problems.

Find any typos? Please let me know I do my best not making them but as a dyslectic it is sometimes really hard so I would appreciate it to drop me a line if you find a typo.