Sevalla is the all-in-one PaaS for your web projects. Host and deploy your applications, databases, object storage, and static sites. Enjoy advanced deployment pipelines, a complete database studio, instant preview apps, and one-click templates. The pricing is simple: no hidden fees, no seat-based pricing, and you pay only for what you use. Get real human support from developers.

Get started now with a $50 credit at Sevalla.com.

Create a global .gitignore

Original – by Freek Van der Herten – 1 minute read

Probably you're using a .gitignore file for every project. If you find yourself creating a .gitignore file for the same files on every project you should use a global .gitignore file. You can specify the location of the global .gitignore file with this command: git config --global core.excludesfile…

Read more

Generate a sitemap in Laravel

Link –

Sitemap is a package built specifically for Laravel 4/5 that will help you generate XML sitemaps for Google. Based on laravel-sitemap this package operates in a slightly different way to better fit the needs of our project. A facade is used to access the sitemap class and we have added the ability to produce sitemap indexes as well as sitemaps. Furthermore, it's tested.
https://github.com/dwightwatson/sitemap

Using this on polkadots.be.

Read more

Stay up to date with all things Laravel, PHP, and JavaScript.

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

How To Add Swap on Ubuntu 14.04

Link –

One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. Swap is an area on a hard drive that has been designated as a place where the operating system can temporarily store data that it can no longer hold in RAM.

The information written to disk will be slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data. Overall, having swap space as a fall back for when your system's RAM is depleted is a good safety net.

In this guide, we'll cover how to create and enable a swap file on an Ubuntu 14.04 server.

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Adding swap is only to be used to give your server a bit of breathing space. If your server is constantly using a lot of swap memory consider upgrading the amount of RAM.

Read more

A Laravel webshop

Original – by Freek Van der Herten – 3 minute read

Earlier today Spatie, the company where I work, launched a webshop polkadots.be. When the project started one of the first choices that we had to make was if we were going to use an existing solution or build our own custom solution. For this project we took an extensive look at some existing…

Read more

Why programmers work at night

Link –

Programmers work at night because it doesn’t impose a time limit on when you have to stop working, which gives you a more relaxed approach, your brain doesn’t keep looking for distractions and a bright screen keeps you awake.
http://en.codeceo.com/why-programmers-work-at-night.html

Though I keep working at night to a minimum it sounds very familiar. It seems a bit strange but not having a deadline is great for productivity for some types of tasks.

Read more

Excel exports

Link –

Evan Miller makes the case for offering xls-exports instead of csv-exports.

Most people of your website’s users are also Excel users. When they export their data as CSV, they’ll probably just bring it into Excel first to have a look around. You should probably offer an explicit XLS export, and take it seriously.
http://www.evanmiller.org/please-offer-an-excel-export-option.html

An xls-file is capable of things that 'll never be possible in csv:

  • freezing the header row
  • formatting important cells
  • multiple sheets in one file
  • specify numer formatting
  • formulas
In the projects I've been working on I've been doing this for a couple of months. A nice Laravel package you can use is Laravel Excel.

This is how you export all values from a given repository that returns Eloquent models:


Excel::create($pathToFile, function($excel) {

    $excel->sheet('The sheet name', function($sheet) {
        $sheet->freezeFirstRow();

        $sheet->cells('A1:Z1', function($cells) {
            $cells->setFontWeight('bold');
            $cells->setBorder('node', 'none', 'solid', 'none');
        });

        $sheet->fromModel($this->yourOwnRepository->getAll());
    });

})->export('xls');

The result is an excel-file with the header row frozen and underlined and it's values in bold.

Read more

MySQL behaviour you should be aware of

Link –

I've used MySQL over the years and it has served me well. I didn't know the default behaviour is a bit messed up. Look at this video for some examples:

Because there's a lot of validation being done by the php-applications I work on, I've yet to run into the problems described above.Though the default configuration has some problems I'm not migrating my current projects from MySQL to something else. But for fresh new projects, I'll consider using PostgreSQL.

If you are considering this as well here's a guide by Chris Fidao (I stumbled upon the video above when reading that guide). If you are in any way interested in running your own server you have to subscribe to his excellent newsletter, Servers for Hackers, and buy the book with the same name.

Read more

Functional programming in PHP

Link –

Almost a year ago Igor Wiedler wrote three articles on his blog about the state of functional programming in PHP.

The first article explores iteration. You'll learn to turn this


$admins = [];
foreach ($users as $user) {
    if (is_admin($user)) {
        $admins[] = $user;
    }
}

into this


use function iter\filter;
$admins = filter('project\user\is_admin', $users);

In the second one he explains a very nice way to traverse an associative array. How you currently do it:


$baz = (isset($data['foo']['bar']['baz'])) ? $data['foo']['bar']['baz'] : null;

How you'll do it in the future:


use function igorw\get_in;
$baz = get_in($data, ['foo', 'bar', 'baz']);

The final article shows you a nice syntax to handle objects that return null-values.

All the articles mention libraries that you can use in your code today.

Read more