Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

Why it's so difficult to add scalar type hints to PHP

On the internals mailing list Anthony Ferrara posted a plea for unity on scalar types. If you want to know why it's so difficult to add scalar type hints to PHP, you should read it.

Scalar types are a hard problem. Not technically, but politically, because so many people use PHP in different ways. And everyone thinks their way is "the one true way".
http://news.php.net/php.internals/84689

The RFC needs a 2/3 majority to pass. The yes-camp currently has 67%. Personally I really hope this proposal will get accepted.

Read more

Why I support the league

Excellent post by Rafael Dohms on the The League Of Extraordinary packages.

“The League of Extraordinary Packages” is what I have dubbed a collective of composer packages. Its essentially a group of developers who have gathered under a single flag (or in this case a vendor name) and set standards for the packages that live there.

...

So these are a few reasons I like this effort:

  • Imposed Quality, Curated List ...
  • Reduced author fragility ...
  • Extended reach ...
  • Reduced duplication ...
http://blog.doh.ms/2015/03/10/why-i-support-the-league/

Read more

How to install MCrypt on Yosemite to enable Laravel Artisan

The accepted solution thus far has been to install newer versions of PHP alongside Apple’s version using Homebrew or MacPorts. This would likely require you to compile the MCrypt extension manually. I also found that Homebrew could leave your system in disarray if things went wrong (more than once I had to do a complete restore because of this).

However, there’s another method I came across while research some non-related issues: install the latest version of PHP from a binary that includes the MCrypt extension. It will not bork up your system if you want to remove it, either.

https://medium.com/@genealabs/run-allthecommands-outside-of-homestead-e2fc8d05251f

Read more

Monitor all proposed changes to PHP

The next major release of PHP, version 7, is going to be an awesome release. Not only will performance be greatly improved, there probably will be lots of nice changes to the language.

The procedure on how PHP gets changed is easily readable and well documented. In short it comes down to this:

  • Proposed changes are submitted on the PHP Wiki.
  • There is a RFC (Request for comments) phase in which key members of the community and contributors can discuss the change.
  • After this round of discussion, which lasts a minimum of two weeks, they can vote if the proposed change gets implemented in a next version of the language.
If you want to closely monitor the future of PHP here's a tool to monitor all activity on the current RFC's.

Read more

A package to backup your Laravel 5 app original

by Freek Van der Herten – 1 minute read

Last week I made a Laravel 5 package that could dump your db. Last saturday night I took the time to expand the functionality. laravel-backup can now backup your entire application. The backup is a zipfile that contains all files in the directories you specify along with a dump of your database. The…

Read more

PHP at the speed of C

Michael Maclean demonstrates how a 2100% performance gain can be achieved when rendering a Mandelbrot fractal using Recki-CT, a PHP compiler written in PHP.

Recently, Anthony Ferrara (known throughout the Internet and beyond as @ircmaxell) and Joe Watkins (similarly well-known as @krakjoe) have been working on a new set of toys for solving this problem while staying on the “standard” PHP runtime. Recki-CT is a set of tools that implement a PHP compiler, in PHP. While this might you think of things like PyPy, which implements a Python virtual machine in Python, this is not Recki’s goal – it doesn’t provide a VM, so it can’t run PHP by itself. However, it can parse PHP code and generate other code from it.
http://mgdm.net/weblog/php-at-the-speed-of-c/

Read more

Using StackPHP middleware in Laravel 5

Middleware is a series of wrappers around your application that decorate the request and the response. By wrapping the app in decorators you can add new behavious from the outside. This image explains the idea more visually:

[caption id="attachment_475" align="alignnone" width="726"]onion source: StackPHP.com[/caption]

 

The concept isn't new, solutions already exists for many languages (eg. Ruby, Python, Node, ...)

The PHP equivalent is StackPHP. Here's an excellent post by Richard Bagshaw explaining it. There are a lot of StackPHP style middlewares available that you can use in your applications.

Laravel 5 uses middleware for putting an application in maintenance mode, CSRF protection, authentication and more. Unfortunately Laravel 5 middleware isn't compatible with StackPHP-style middleware. Barry vd. Heuvel created at package to convert StackPHP middleware to Laravel 5 middleware and explained the inner workings on his blog.

Read more

Building Gistlog

Matt Stauffer shows how he built Gistlog in under two hours.

Gistlog is a blogging "platform" for people who want to quickly write and publish content, in Markdown, and don't want to bother with yet another platform and yet another login and yet another group hoarding their content. With Gistlog, you use your pre-existing Github login, you store the data in your own Github account, and you can publish with a single click.
A must see if you want to know how to get things done quickly in Laravel.

https://www.youtube.com/watch?v=g4BbeHYCR1E

Also make sure you check out his blogposts on the new features of Laravel 5.

Read more

Some Laravel 5 compatible packages

Recently some of the Laravel-packages I built at Spatie were updated for Laravel 5.

spatie/laravel-glide This package enables you to generate image manipulations on the fly and generate URL's to those images. These URL's will be signed so only you will be able to specify which manipulations should be generated. Every manipulation will be cached. Under the hood, Glide is being used.

spatie/searchindex This is an opinionated package to store and retrieve objects from Elasticsearch. It was tailormade for a project I was working on and only provides the functionality that I needed. If you need full control over elasticsearch via PHP, take a look at the official low-level client.

spatie/googlesearch This package can fetch results from a Google Custom Search Engine. It returns an array with searchresults.

eloquent-sortable This package provides a trait that adds sortable behaviour to an Eloquent model. The value of the ordercolumn of a new record of a model is determined by the maximum value of the ordercolumn of all records of that model + 1.

 

A big thank you goes out to Matthias De Winter, who is helping me update these packages.

Read more

Scalar type hints vote cancelled

For my own reasons, I have decided to cease my involvement with PHP development. This isn’t a judgement of the PHP community nor the internals mailing list, you’re all wonderful people and it’s really been a pleasure, and I mean that completely honestly. However, this has ended up taking up too much of my time (which is my own fault, and my own fault alone) and I can’t really justify it to myself anymore.

So, I’m no longer contributing to PHP, and all four active RFCs authored by myself are therefore withdrawn: Scalar Type Hints, Spaceship/Combined Comparison Operator, Void Return Type, Big Integer Support.

http://news.php.net/php.internals/82750

Damn.

Read more

Running Symfony2 on PHP7

This chart shows the number of requests per second that were performed (more is better). You can see that PHP 7 can do a lot more in comparison with the other versions. Response times drop from 0.2269 to 0.0865 seconds in the production environment.
http://www.intracto.com/nl/blog/running-symfony2-on-php7

Nice benchmark-work by Tom Van Looy. It is clear that you'll benefit from impressive speed bumps when upgrading to the next major version of PHP. Tom also provides instructions on how to setup PHP7 so you can perform your own tests.

Read more