How modern SQL databases come up with algorithms that you would have never dreamed of
In an amazing (and funny) talk Lukas Eder demonstrates how powerful SQL (or any 4th generation programming language) really is.
In an amazing (and funny) talk Lukas Eder demonstrates how powerful SQL (or any 4th generation programming language) really is.
In a new post on his Medium Blog, Laravel.io maintainer Dries Vints wrote how he managed do drastically improved the build time of the popular forum.
CircleCI 2.0’s builds run with Docker which makes spinning up new instances super fast. If you use pre-built images which are customized to your needs, you don’t even need to do any provisioning during the build which saves you quite a bit time. Pulling various images and orchestrating them in a CircleCI 2.0 config allows for very rapid build times. If you add their new workflows to their mix you could easily enable parallelization and speed things up even more.
https://medium.com/laravelio/how-circleci-improved-our-build-time-8d5c40b8cc60
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.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
If you find yourself having a bunch of slow tests that don't need to execute every time you run the tests, take a look at PHPUnit's defaultTestSuite setting. TJ Miller explains it in a blog post he wrote last year.
To avoid running the interactive test suite with the rest of my tests, manually or via a CI job, I had to explicitly include all the other suites using phpunit --testsuite Api,Feature,Unit. This felt a bit grim and I would rather exclude just that one suite. So I did some digging and found the defaultTestSuite configuration for phpunit.
https://medium.com/@sixlive/separate-interactive-test-suites-f6fd59316ec2
laravel-medialibrary is a powerful package that can help handle media in a Laravel application. It can organise your files across multiple filesystems, generate thumbnails, optimize images and much much more. At Spatie we use this package in nearly every project. The last few months our team has…
Our team is currently prepping a new version of our medialibrary. One of the highlights is support for responsive images. On his blog my colleague Brent explains what it entails and why it is important.
I want to share some thoughts on responsive images. I'll write about a certain mindset which many projects could benefit from: small- and mid-sized web projects that don't need a full blown CDN setup, but would enjoy the performance gain of responsive images.
https://www.stitcher.io/blog/responsive-images-done-right
Today at the JSConf in Iceland, React core developer Dan Abramov demonstrated some very cool features that will soon land in React.
We’ve built a generic way to ensure that high-priority updates don’t get blocked by a low-priority update. We call this time slicing. If my device is fast enough, it feels almost like it’s synchronous; if my device is slow, the app still feels responsive. We’ve also built a generic way for components to suspend rendering while they load async data. We call this feature suspense. You can pause any state update until the data is ready, and you can add async loading to any component deep in the tree without plumbing all the props and state through your app and hoisting the logic.
https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-16.html
In a new post on his blog Matthieu Napoli, creator of PHP-DI, explains how he made v6 much faster.
But the good thing is that, after 6 years of existence, the project has matured and is now quite stable. The original objectives are met, even though there is of course always room for improvements and innovation. There is room to push the container to be better on other levels. And the most obvious one is performances.
PHP-DI 6 will be much, much faster because it is a compiled container.
http://php-di.org/news/21-php-di-6-compiled-container.html
Collin O' Dell, member of the PHP League, shares how he was able to significantly improve the performance his json5 package using Blackfire profiling.
Back in November I released colinodell/json5 - a JSON5 parser for PHP. It's essentially a drop-in replacement for PHP's json_decode() function, but it allows things like comments, trailing commas, and more.
...
I always knew that a PHP-based implementation would be slower than PHP's native C implementation, but execution time measured in minutes was completely unacceptable!
So I fired up Blackfire (which I've previously used to optimize league/commonmark) and got to work.
https://www.colinodell.com/blog/201801/optimizing-colinodelljson5-blackfire
In a post on vuejsdevelopers.com Anthony Gore explains how to get started with serverside rending with Laravel and Vue. Cool stuff!
Server-side rendering is great way to increase the perception of loading speed in your full-stack app. Users get a complete page with visible content when they load your site, as opposed to an empty page that doesn’t get populated until JavaScript runs.
One of the downsides of using Laravel as a backend for Vue.js was the inability to server render your code. Was. The release of Vue.js 2.5.0 has brought server-side rendering support to non-Node.js environments including PHP, Python, Ruby etc.
In this tutorial, I’ll take you through the set up steps for Laravel and demonstrate a simple server-rendered app. Get the code for this here on Github.
https://vuejsdevelopers.com/2017/11/06/vue-js-laravel-server-side-rendering/
My colleague Brent is currently creating a new package called spatie/async. This one will let you easily do some asynchronous parallel processing in PHP. In a new post on his blog Brent explains why we are creating the package and compares it to a few other solutions out there.
If you're into parallel PHP, you probably heard of Amp and ReactPHP. Our package aims not to compete with those two, as it only solves one tiny aspect of parallelism in PHP. We did however use both the packages to run some benchmarks against. Let's take a look at the results.
https://www.stitcher.io/blog/asynchronous-php
Laravel has an excellent Collection class that has many useful operations. The class is also macroable. This means that you can add function to it at runtime by calling macro on it and passing a name and a closure. In our projects we tend to code up the same macro's over and over again. That's why…
Using regular UUIDs stored as a text-based primary key is very slow. Our newly released package spatie/laravel-binary-uuid aims to solve that by binary storing a slightly tweaked version of the UUID. My colleague Brent wrote a blogpost describing how it works behind the scenes. He also included some interesting benchmarks.
The binary encoding of UUIDs solved most of the issue. There's one extra step to take though, which allows MySQL to even better index this field. By switching some of the bits in the UUID, more specifically time related data, we're able to save them in a more ordered way. And it seems that MySQL is especially fond of ordered data when creating indices.
https://www.stitcher.io/blog/optimised-uuids-in-mysql
In a new blogpost published at Sitepoint, Christopher Pitt explores the various ways you can handle reading big files in PHP.
Though this isn’t a problem we frequently suffer from, it’s easy to mess up when working with large files. In asynchronous applications, it’s just as easy to bring the whole server down when we’re not careful about memory usage.
This tutorial has hopefully introduced you to a few new ideas (or refreshed your memory about them), so that you can think more about how to read and write large files efficiently. When we start to become familiar with streams and generators, and stop using functions like file_get_contents: an entire category of errors disappear from our applications. That seems like a good thing to aim for!
Probably you know that that keeping the disk & transfer size of a JavaScript file low is pretty important. But have you considered the time needed to parse and compile the code? In this great post on Medium Addy Osmani, an engineer at Google, explains the complete cost of having JavaScript on your page.
As we build sites more heavily reliant on JavaScript, we sometimes pay for what we send down in ways that we can’t always easily see. In this post, I’ll cover why a little discipline can help if you’d like your site to load & be interactive quickly on mobile devices. tl;dr: less code = less parse/compile + less transfer + less to decompress
https://medium.com/dev-channel/the-cost-of-javascript-84009f51e99e
PurgeCSS is a tool that can reduce the filesize of a CSS file. It does this by removing any css classes that are not used. It can detect which CSS classes are used by scanning the source files of your application. In this tweet Jonathan Reinink shared how it can be configured in Laravel Mix: ???? I…
yes is a Unix command that will spit out and infinite stream of y's. In a post on his blog Matthias Endler, an engineer at trivago, shares that there's more than meets the eye to make this happen in a performant way.
The trivial program yes turns out not to be so trivial after all. It uses output buffering and memory alignment to improve performance. Re-implementing Unix tools is fun and makes me appreciate the nifty tricks, which make our computers fast.
PhpStorm is a fantastic editor. Unfortunately it can be quite slow. Brent, one of our developers at Spatie, blogged a few tips to make it run a bit faster. I've followed all his suggestions and PhpStorm now feels a bit more responsive.
I didn't start this post by writing my own thoughts, because I figured people were looking for some quick tips to speed of their IDE. As a PHP developer, I think that PhpStorm is such a powerful tool, which helps me to write good and maintainable code. I don't want it to stand in my way though, so good performance is an absolute requirement.
https://www.stitcher.io/blog/phpstorm-performance
Hopefully future versions of PhpStorm will be more performant out of the box.
On his blog Mathias Bynens explains the differences under the hood between async/await and vanilla promises.
The fundamental difference between await and vanilla promises is that await X() suspends execution of the current function, while promise.then(X) continues execution of the current function after adding the X call to the callback chain. In the context of stack traces, this difference is pretty significant. ... Enable JavaScript engines to handle stack traces in a more performant and memory-efficient manner by following these recommendations:
- Prefer async/await over desugared promises.
- Use babel-preset-env to avoid transpiling async/await unnecessarily. ...
Addy Osmani, a Google Chrome engineer, recently published a e-book on image optimization. You can read it in it's entirety here: https://images.guide/
Images take up massive amounts of internet bandwidth because they often have large file sizes. According to the HTTP Archive, 60% of the data transferred to fetch a web page is images composed of JPEGs, PNGs and GIFs. As of July 2017, images accounted for 1.7MB of the content loaded for the 3.0MB average site.Per Tammy Everts, adding images to a page or making existing images larger have been proven to increase conversion rates. It's unlikely that images will go away and so investing in an efficient compression strategy to minimize bloat becomes important.
If you need to optimize images in your PHP application take a look at our image optimization package. If you're a Laravel user you'll be happy to know that there's also a Laravel version of the optimizer. Our Laravel Medialibrary also comes with built-in support for optimizing images.
To view some real time statistics of your server you use top or htop. But there's a new new kid on the block: gtop. It looks pretty nice.