Anatomy of a PHP Hack

Aaron Saray recently found some rogue code on a hacked website and investigated what it actually does.

It’s hard to come up with a title for this - but - basically I found some rogue code the other day that I thought was pretty interesting. I was fixing a “hacked” website when I came across the source of the symptoms of the hack.

This obfuscated code is doing something bad, but we don’t know what at first glance. Obviously, the solution is to remove it - but - aren’t you a little curious what it was doing? Let’s take a look.

https://aaronsaray.com/2017/anatomy-of-a-php-hack.html

Read more

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.

On migrating my blog from WordPress to a Laravel application original

by Freek Van der Herten – 12 minute read

Regular visitors will have noticed that last week this blog got a new coat of paint. This new layout isn't just a new WordPress theme. Things have changed on the backend as well. Previously my blog was powered by WordPress. I've migrated it to a custom built Laravel app. That app is open sourced.…

Read more

Improve the error output of console commands in a Laravel app

If you execute an Artisan command and something goes wrong, the error output is not terribly detailed.

You can improve the output slightly by tagging on -vvv to make to output more verbose.

Now we already know the line that where the problem originates: there's something going wrong on line 41 of the MyBrokenCommand command.

But we can improve the error output still. Nuno Maduro coded up a fantastic package called Collision that, once installed, provides much nicer output.

In this output we can immediately see what the silly programmer did wrong.

Let's hope that a future version of Laravel will be able to spit out these nicely formatted errors out of the box.

Read more

PHP Versions Stats - 2017.2 Edition

Every six months Jordi Boggiano, co-creator and maintainer of Composer/Packagist, publishes statistics on which versions of PHP are used. Some good news: PHP 7.1 is the most used version.

A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. I look in the packagist.org logs of the last month for Composer installs done by someone. Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with.

https://seld.be/notes/php-versions-stats-2017-2-edition

Read more

A beautiful webapp to fetch dns records original

by Freek Van der Herten – 3 minute read

Recently my company Spatie launched https://dnsrecords.io, a beautiful site to quickly lookup dns records. True to form, we also opensourced it, here is the sourcecode on GitHub. If you want to do some dns lookups in your own app, you'll be happy to know that we extracted the dns lookup…

Read more

Backup multiple sites and frameworks with Laravel Backup

Tim MacDonald, a freelance software developer living in Australia, wrote down how he used our backup package to backup his Laravel and Wordpress sites.

I’m not going to run you through the standard setup or all the great features of the package here, you should definitely get your feet wet and give it a go. You’ll be up and running with backups in no time at all. From here on I’ll assume you’ve had some experience with the package, as to not over explain every step along the way…I do tend to rant off topic otherwise ?

I wanted to have a standardised backup system in place for all my sites. This system would have to include Laravel and WordPress installs - so I tinkered with Spatie’s Laravel Backup package and have managed to get a single install of Laravel to backup all my sites independently, including my WordPress sites ?

https://timacdonald.me/backup-multiple-sites-frameworks-laravel-backup/

Read more

Improving the performance of PhpStorm

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.

Read more

Debugging the dreaded "Class log does not exist" error in Laravel

My colleague Sebastian took the time to write down the solution to a problem many artisans will come across at some point in time. I hope that in a future version of Laravel that error message will be improved so that it makes clear what the actual problem really is.

Every now and then I come across a Class log does not exist exception in Laravel. This particular exception is thrown when something goes wrong really early in the application, before the exception handler is instantiated.

Whenever I come across this issue I'm stumped. Mostly it's related to an invalid configuration issue or an early service provider that throws an exception. I always forget how to debug this, so it's time to document my solution for tracking down the underlying error.

https://sebastiandedeyne.com/posts/2017/debugging-the-dreaded-class-log-does-not-exist-error-in-laravel

Read more

A Laravel package to log HTTP requests original

by Freek Van der Herten – 1 minute read

Most of the sites we build for our clients contain some sort of contact form. For those client such forms are potentially critical to their business. Imagine for instance a real estate firm that generates leads with such forms. In most cases we will store the submitted values in the db and mail them…

Read more

Dockerize your Laravel app with Vessel

Chris Fidao has created an easy to handle, well documented, Docker dev environment for Laravel projects. It's an excellent starting point if you want to have a taste of what Docker can do.

For the introductory newsletter:

I like Vessel the best for the following reasons: 1. It's installed per-project instead of globally. This lets me customize it per project if need be. 2. Docker lets me change out versions of software such as Nginx, MySQL, Redis, and others very easily. (I've often needed to use an older MySQL version at work) 3. Docker lets me add extra software (perhaps Beanstalkd for queues, or PgSQL for database) really easily 4. Docker containers are more like processes than VMs. They generally only use what resources they need (with some caveats, but even with those, they're lighter than Vagrant virtual machines) 5. I can fill up my workstation with one technology (Docker!) instead of many (PHP, Redis, MySQL, etc) with all their configuration files and data strewn about all over my file system 6. You can expand on your dev workflow to build up to a production workflow using all the same technology (Docker!) - You can check out Shipping Docker for my full course on bringing Docker from dev into production.

https://vessel.shippingdocker.com

Read more

Handling Stripe webhooks in a Laravel application original

by Freek Van der Herten – 5 minute read

In the project I'm currently working on I had to integrate Stripe webhooks. Stripe has great documentation on how to handle webhooks, but it still took a fair amount of time to get the integration just right. My solution for handling webhooks is pretty generic and reusable by others. I decided to…

Read more