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.

Overriding Laravel's helper functions

Link –

Miklós Galicz posted a short article on how he managed to override Laravel's str_slug helper function.

Long story short, until this is resolved one way or another... A really obscure but powerful tool can be a temporary solution for this. It's called Helper Overloading. Laravel's helpers are created in a way that checks if the method already exists. ... This is really great, the only thing remaining is to actually add our own method before Laravel creates it own version.

https://blackfyre.ninja/blog/fixing-slug-generation-problems

Read more

Symfony and Laravel will require PHP 7 soon

Link –

According to Fabien Potencier, lead of the Symfony project, the next major version of Symfony, to be released at then end of 2017, will require PHP 7.

But Laravel will drop PHP 5 support even sooner. Taylor Otwell, the creator of Laravel, announced that Laravel 5.5, to be released in June 2017, will leave PHP 5 behind.

On multiple occasions Taylor et co. have stated that they don't like the strictness that things like scalar and return type hints bring to the table. So I don't expect to see them appear much in Laravel codebase. Smaller syntax improvements like for example the null coalescing operator will almost certainly be used.

A few weeks ago Jordi Boggiano reported that only a miserable 3% of all packages present on Packagist require PHP 7. The best thing about Symfony and Laravel dropping PHP 5 support is that it will send a strong message throughout the entire PHP ecosystem that you shouldn't bother with PHP 5 code anymore. When creating new projects and packages more developers will target PHP 7 as a minimum version as well.

For our PHP and Laravel packages we left PHP 5 behind as soon as PHP 7 was available. Our packages already make extensive use of return type hints, anonymous classes and the null coalescing operator to create more readable (and thus more maintainable) code.

(Fun Scary fact: Wordpress only requires PHP 5.2 ?)

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.

Introducing Private Packagist

Link –

Jordi Boggiano and Nils Adermann, creators of Composer, have recently released a paid version of Packagist. The service aims to make managing private packages a breeze.

Private Packagist aims to remove all these hurdles for businesses to finally make working with Composer as convenient as it should be. Being a hosted service, setting up your own Composer package repository on Private Packagist is done with a few clicks. No matter if your private source code is hosted on GitHub, GitLab, Bitbucket, any of their on-premise solutions, or in any other Git, Mercurial, or Subversion repository, Private Packagist can immediately access your code after setting up your credentials to make it available for installation through Composer.

https://medium.com/packagist/introducing-private-packagist-492553d10660

If you're not afraid to get your hands dirty you could, instead of using Private Packagist, choose to use Satis. This tool is also written by Jordi & Nils. Laravelista has posted this great tutorial to get you started with the tool.

At Spatie we have set up a satis server to register packages that are intended to only be used in our own projects.

Read more

An introduction to functional programming

Link –

On Egghead.io there's a free course available on functional programming. Your teacher is Professor Frisby, who is in fact a hedgehog. Yup, you've read that right. The tempo of the course is quite fast, so you might have to, like me, pause or rewatch the videos to get the most out of it.

This course teaches the ubiquitous abstractions for modeling pure functional programs. Functional languages have adopted these algebraic constructs across the board as a way to compose applications in a principled way.

We can do the same in JavaScript. While the subject matter will move beyond the functional programming basics, no previous knowledge of functional programming is required. You'll start composing functionality before you know it.

https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript

Read more

Scaling Laravel Using AWS Elastic Beanstalk

Link –

Elastic Beanstalk is a service by Amazon that can automatically scale an application. Gilbert Pellegrom published a second blogpost in his series on how to get Laravel up and running on the service.

In my last article we decoupled Laravel and got it ready for deployment to the Elastic Beanstalk architecture. However, before we race ahead to actually deploying our code to Elastic Beanstalk we need to do some preparation first. Specifically we need to set up some other AWS services that will be used by our Laravel app. These include:
  • Virtual Private Cloud (VPC) to keep our infrastructure secure
  • Relational Database Service (RDS) for our MySQL database
  • ElastiCache for our Redis cache

With these “supporting” services up and running we can finally move on to deploying our Laravel app to Elastic Beanstalk.

https://deliciousbrains.com/scaling-laravel-using-aws-elastic-beanstalk-part-2-setting-up-vpc-rds-elasticache/

Read more

An easy to install uptime monitor

Original – by Freek Van der Herten – 4 minute read

A few weeks ago we released our uptime and ssl certificate monitor. It's written in PHP and distributed as a Laravel package. If you're familiar with Laravel that's all fine, but if you have no experience with that (kick ass) framework, it's a bit difficult to get started with using our uptime…

Read more

Human Readable AJAX Requests

Link –

Zach Silveira made a new JavaScript library that aims to make ajax requests much more readable. Under the hood template literals are used.

Anyone familiar with HTTP requests knows what each line in chrome's network tab means. It's too bad we can't copy and paste this into our code and do that exact request..... But we can (almost), if my idea pans out! Take a look at what I'm proposing:
request`  
  url: http://test.app/settings/user/19
  method: PATCH
  headers: ${{ 
    Authorization: 'Bearer: token' 
  }}
  body: ${{ name: 'Bob' }}
`

https://zach.codes/human-readable-ajax-requests/

Read more

Why you should be giving your developers 20% time

Link –

On the Tighten blog Samatha Geitz sums up the benefits of giving developers one day of "free" time a week.

About a year ago, Tighten officially implemented a "20% time" policy for its developers. This means that, on any given week, we only bill our clients for 32 hours of developer work; for the other 8 hours, developers can work on whatever projects they’d like to (as long as they can readily come up with an explanation of how it benefits the company in some way.) ... Here are some reasons that you may want to consider experimenting with a policy like this

https://blog.tighten.co/give-your-developers-20-percent-time

Read more

A developer friendly wrapper around Fractal

Link –

Fractal is an amazing package to transform data before using it in an API. Unfortunately working with Fractal can be a bit verbose. That's why we created a wrapper called Fractalistic around it, that makes working with Fractal a bit more developer friendly. It's framework agnostic so you can use it in any PHP project.

Using the vanilla Fractal package data can be transformed like this:

use League\Fractal\Manager;
use League\Fractal\Resource\Collection;

$books = [
   ['id'=>1, 'title'=>'Hogfather', 'characters' => [...]], 
   ['id'=>2, 'title'=>'Game Of Kill Everyone', 'characters' => [...]]
];

$manager = new Manager();

$resource = new Collection($books, new BookTransformer());

$manager->parseIncludes('characters');

$manager->createData($resource)->toArray();

Our Fractalistic wrapper package makes that process a tad easier:

Fractal::create()
   ->collection($books)
   ->transformWith(new BookTransformer())
   ->includeCharacters()
   ->toArray();

There's also a very short syntax available to quickly transform data:

Fractal::create($books, new BookTransformer())->toArray();

If you want to use this package inside Laravel, it's recommend to use laravel-fractal instead. That package contains a few more bells and whistles specifically targetted at Laravel users.

To learn all the options Fractalistic has to offer, head over to the readme on GitHub. If you like it, take a look at our previous open source work as well. There's a list of framework agnostic packages we made on our company site.

Read more

How to automate projects using composer scripts

Link –

On the Master Zend Framework blog Matthew Setter explains the scripts section of composer.json.

The scripts section of composer.json allows you to set up a range of commands which relate to your project, commands which call command-line executables and PHP callbacks.

The commands can be named as you see fit, such as test, clean, deploy and so on. Or they can use the names of events which Composer fires during its execution process, such as post-root-package-install, pre-install-cmd, and post-package-update.

In today’s tutorial, I’m going to take you through examples which highlight both approaches

http://www.masterzendframework.com/series/tooling/composer/automation-scripts/

Read more

A package to fluently generate schema.org markup

Original – by Freek Van der Herten – 2 minute read

Schema.org is a vocabulary of microdata markup that aims to make it easer for search crawlers to understand what's on a webpage. The vocabulary is very extensive: here's the official list of things that can be described with Schema.org. This article on Tutsplus explains schema.org and structured…

Read more

The delicious evils of PHP

Link –

In a post on Sitepoint Christopher Pitt demonstrates some cool usages of eval and exec.

I want to look at two PHP functions: eval and exec. They’re so often thrown under the sensible-developers-never-use-these bus that I sometimes wonder how many awesome applications we miss out on.

Like every other function in the standard library, these have their uses. They can be abused. Their danger lies in the amount of flexibility and power they offer even the most novice of developers.

Let me show you some of the ways I’ve seen these used, and then we can talk about safety precautions and moderation.

https://www.sitepoint.com/the-delicious-evils-of-php/

Read more

Upgrading to PHP 7.1 is easy

Original – by Freek Van der Herten – 2 minute read

PHP 7.1 was released last week. It has many nice new features. If you're anything like me, you want to use the latest version right way. Upgrading to PHP 7.1 is not that difficult. Personally I use homebrew. The steps required to upgrade from 7.0 are laughably simple. Just issue this command in your…

Read more

Improving the performance of our PHP based crawler

Original – by Freek Van der Herten – 2 minute read

Today a new major version of our homegrown crawler was released. The crawler is used to power our http-status-check, laravel-sitemap and laravel-link-checker packages. A new major feature is the greatly improved crawling speed. This was accomplished by leveraging multiple concurrent requests. Let's…

Read more

Some request filtering macros

Link –

In a gist on GitHub Adam Wathan shares some macros that can be used to clean up a request.

Allows you to trim things, lowercase things, whatever you want. Pass a callable or array of callables that each expect a single argument:
Request::macro('filter', function ($key, $filters) {
    return collect($filters)->reduce(function ($filtered, $filter) {
        return $filter($filtered);
    }, $this->input($key));
});

https://gist.github.com/adamwathan/610a9818382900daac6d6ecdf75a109b

If you want to hear Adam talk some more about troubles with requests (generated by webforms) and possible solutions, listen to this episode of the Full Stack Radio Podcast.

Read more

No Time for a Taxicab

Link –

Gary Hockin posted a video with his attempt in solving the Day 1 challenge of http://adventofcode.com/. The video not only shows how he solved the problem codewise but also demonstrates some nice features of PHPStorm.

Mistakes and all, I attempt to code day 1 part 1 of the Advent of Code challenges you can find at http://adventofcode.com.

I deliberately didn't overly edit, or over complicate the video as I'm trying to get them done as fast as possible, if you like this I'll do some more!

I know some people will say "Waaa you should have done it like this!", or "Why didn't you use library $x", well I didn't so get over it. I'm also worried this gives away far too much about my coding quality and how lazy I am, but such is life.

Read more

How I refactor to collections

Link –

Christopher Rumpel posted some good practical examples on how to refactor common loops to collections.

Refactoring to Collections is a great book by Adam Wathan where he demonstrates, how you can avoid loops by using collections. It sounds great from the beginning, but you need to practice it, in order to be able to use it in your own projects. This is why I refactored some of my older projects. I want to share these examples today with you.

http://christoph-rumpel.com/2016/11/How-I-refactor-to-collections/

Read more

Clean up your Vue modules with ES6 Arrow Functions

Link –

On the .dev blog Jacob Bennett shared some nice refactorings using arrow functions.

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

https://dotdev.co/clean-up-your-vue-modules-with-es6-arrow-functions-2ef65e348d41

Read more