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.

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.

PHP-FIG has a new beautiful site

Link –

One of the most important endeavors in the PHP universe is the PHP Framework Interop group. The group consists of several maintainers of big PHP projects. Their aim is to find commonalities between their projects and find ways to work together. They do this by proposing and accepting PSR's, short for PHP Standard Recommendation.

One of the most important PSR's is PSR-4 (and the now deprecated PSR-0) which describes a way to autoload classes. Thanks to this standard packages can be easily be reused in many frameworks and projects. PSR-2 is another important one. It is a coding style guide and greatly improves readabiltiy of code when working with a bunch of developers. There are several other PSR's that have been accepted.

Today PHP-FIG published their new site. It features a beautiful design by Jonathan Reinink (he's the designer of the PHP League sites, author of Glide, and creator of the PHP Package checklist). If you use PHP in any way you owe it to yourself to check it out the new site.

 

Read more

A pjax middleware for Laravel 5

Original – by Freek Van der Herten – 1 minute read

A few days ago Jeffrey Way published an interesting lesson on how to integrate pjax with Laravel. Pjax is jquery plugin that leverages ajax to speed up the loading time of webpages. It works by only fetching specific html fragments from the server, and client-side updating only certain parts of the…

Read more

Why developers hate being interrupted

Link –

Developers can appear very unproductive at times, sitting staring at the screen with our headphones on and very little in the way of keyboard clackety-tap. This however is when we are doing our thinking, when we are building up, adding to and rearranging the mental model of how our code will work. This is the biggest and hardest part of development.

Imagine how it feels to have that interrupted at random by a telephone call or somebody walking over to talk to you. It’s horrible.

http://thetomorrowlab.com/2015/01/why-developers-hate-being-interrupted/

Read more

The beginner's guide to rebasing your PR

Link –

You've successfully created a PR and it's in the queue to be merged. A maintainer looks at the code and asks you to rebase your PR so that they can merge it.

Say what?

The maintainer means that there have been other code changes on the project since you branched which means that your branch cannot be merged without conflicts and they would like to you to sort this out.

These are the steps you should take.

http://akrabat.com/the-beginners-guide-to-rebasing-your-pr/

Read more

Custom conditionals with Laravel's Blade Directives

Link –

Matt Stauffer explains when and how you can leverage custom blade directives.

One of the greatest aspects of Laravel Blade is that it's incredibly easy to handle view partials and control logic. I find myself frequently extracting the contents of a loop out to a Blade partial and then passing just a bit of data into the partial.

But sometimes the repetitive code isn't the view itself, but the conditional logic I'm running.

https://mattstauffer.co/blog/custom-conditionals-with-laravels-blade-directives

Read more

A Fractal service provider for Laravel

Original – by Freek Van der Herten – 1 minute read

Today I released a new package called laravel-fractal. It provides a Fractal service provider for Laravel. If you don't know what Fractal does, take a peek at their intro. Shortly said, Fractal is very useful to transform data before using it in an API. Using Fractal data can be transformed like…

Read more

How to perform a HTTP/2 Server Push with the Symfony HttpKernel

Link –

HTTP/2 has a great feature called server push. It enables the server to send multiple responses in parallel for one request. In a blogpost on the Symfony Finland blog Jani Tarvainen demonstrates how to make use of server push with the Symfony Kernel.

$app->get('/images'), function () use ($app) {
    $images = array('/images/1.jpg','/images/2.jpg','/images/3.jpg');
    $response = new JsonResponse($images);
    foreach($images as $image){
        $response->headers->set('link','<' . $image . '>; rel=preload; as=image',false);
    }
    
    return $response;

Read the entire article for some more background info.

Read more

Add a JavaScript breakpoint programmatically

Link –

When working on JavaScript code you'll probably find yourself riddling the code with console.log-statements when something is not working the way that you're expecting.

But did you know that there is a debugger statement available? It has invokes any available debugging functionality. To put it otherwise: you can programmatically set a breakpoint for your debugger. It should work in any browser.

function potentiallyBuggyCode() {
    debugger; //the debugger wil stop here
}

Here's the documentation on the debugger-statement on MDN.

Read more

I crashed the web servers of a $100M+ multi-national corporation

Link –

A great story by Derick Bailey of Watchmecode.net

The important lesson, ..., was that I owned up to the mistake, dug in and fixed it, and learned how to avoid the problem in the future. I was, in his mind, a better developer at the end of that day. I had survived a catastrophic crash of my own making and I had fixed the problem, learning some very valuable lessons in business down time and in code that day.
http://derickbailey.com/email_archive/i-crashed-the-web-servers-of-a-100m-multi-national-corporation/

Read more

Do not trust cat at the command line

Link –

In this excellent post Matthias explains why you can't put all your trust in cat when inspecting a file:

https://ma.ttias.be/terminal-escape-sequences-the-new-xss-for-linux-sysadmins/

Let's all agree to never trust anything that has been posted on the internet without very thorough inspection. And let's especially agree to never run an arbitrary command or script found on the internet, without really close inspection.

Read more