What about "final" and "private"?

There was much discussion on Twitter about the concepts of using “final” and “private” in objects, and what exactly the best practices are. The conversation seemed to boil down to three distinct questions:
  • Should an object be open for extension, and expose its internals for that purpose?
  • Does exposure of those internals create a de facto contract with children for their behavior?
  • Should software only be used as intended by its designers, or should it be modified, extended and changed by the end user to fit certain, specific goals?
http://www.brandonsavage.net/what-about-final-and-private/

Read more

PHPUnit 5.0 will only support PHP5.6 and above

Active support for PHP 5.4 ended on September 14, 2014 and active support for PHP 5.5 will end on June 20, 2015. The active support for PHP 5.3 already ended on July 11, 2013. By the time PHPUnit 4.8 will be released, the only actively supported version of PHP will be PHP 5.6.

The next version after PHPUnit 4.8 will not support PHP 5.3, PHP 5.4, and PHP 5.5 anymore. As PHPUnit follows Semantic Versioning the major version number must be incremented when the minimum required version of PHP is increased.

https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.7.0#phpunit-50

Nice!

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.

Handling private composer packages with Satis

Satis allows you to require private php packages in your projects. One of it's authors is Jordi Boggiano of composer/packagist fame. Over at the excellent Laravelista blog Mario Bašić explains how to install and use it.

I was working on three projects at the same time and I've found myself copying code from one project to another and then making small changes. And then I recognized a pattern. ...

I created a package and as soon as it was ready for GitHub I remembered: "I can't open source this...". The package contained few paid html templates, company logo's, slogans, specific company text etc. ...

This post will explain what Satis is, when to use it and how to set it up on your server.

Read more

Get data from Google Analytics on legacy sites

Nearly all greenfield projects at Spatie are built with Laravel. A few months ago I made laravel-analytics, a package to fetch data from Google Analytics.

Spatie exists for more than ten years so there are quite a few legacy projects as well. In those projects there is also a need to display some analytics data in the admin-section. Recently Google retired some of their older API's. Unfortunately our old solution to fetch GA data stopped working.

To resolve this problem my colleague Sebastian created a framework agnostic version of laravel-analytics that works with PHP 5.3. If you also have a legacy project that needs some data from Analytics, you can install the package via composer.

Read more

Learn by listening to these podcasts

The past few months, I've been trying out some podcasts. Listening to them is an easy way to learn about and stay in touch with the sprawling range of topics that could interest a developer. These are my favourites:

The Laravel Podcast

The Laravel podcast focusses on Laravel (of course) and the latests trends in the PHP world. The podcast is hosted by Matt Stauffer. Jeffrey Way and Taylor Otwell are regular guests. Recently the format of the show was changed: episodes are now around 30 minutes in length, which I think is great.

Listen in iTunes Follow on Twitter

Full Stack Radio

This podcast isn't narrowly focused on one subject. In each episode Adam Watham interviews one guest. Topics range from product design to system administration and everything in between. To give you an idea: the last episodes saw Adam Culp talking about conferences, Kent Beck about application architecture and Konstantin Kudryashov about BDD and TDD.

Listen on iTunes Follow on Twitter

Dev Discussions

In this podcast Shawn McCool talks with other webapplication dev's mainly about programming concepts. Past episodes touched functional programming, event sourcing, ActiveRecord and Datamapper. Shawn recently recorded a talk with Mathias Verraes and Ross Tuck. Let's hope it gets published soon.

Listen on iTunes Follow on Twitter

PHP Roundtable

The roundtable was created by Sammy Kaye Powers. On each episode several developers discuss various topics concerning PHP and it's ecosystem.

Listen on iTunes Follow on Twitter

I'm sure there are many other great podcasts out there. If you know one, please let me (and the other readers of this blog) know in the comments below.

Read more

Creating packages original

by Freek Van der Herten – 2 minute read

Prosper Otemuyiwa recently wrote an article on how to create Laravel 5 packages on his blog. Although his approach is entirely valid and may suit you well, I work a little differently when creating a new package. First, I create a new GitHub repository where the package will live. In that repo I…

Read more

The benefits of creating packages original

by Freek Van der Herten – 1 minute read

In the last few months various little parts of our custom built CMS were made available as composer installable packages. Though creating a package takes some time, there are many benefits: my colleagues and my future self can benefit from the same documentation that is written for the consumers of…

Read more

Manage newsletters in Laravel 5 original

by Freek Van der Herten – 1 minute read

A few hours ago I tagged version 1.0.0 of a my new package: laravel-newsletter. It provides a very easy way to interact with email marketing services. Or maybe I should simply say MailChimp, as it is currently the only supported supported service. After you install the package (un)subscribing an…

Read more

Modern PHP hosting

Over at the Fortrabbit-blog grown up graffiti kid Frank Lämmer provides an excellent overview of what your options are when looking for PHP-Hosting.

Let’s face it: web hosting is a market for lemons. There are so many providers. New categories are emerging. Borders blur. Microservices everywhere. It’s complex. It’s noisy. It’s hard.
http://blog.fortrabbit.com/php-hosting-possibilities

I used to work with providers that offered sharing hosting that could be administered with tools like Plesk and cPanel. The biggest drawbacks of shared hosting are that these environments don't get updated regularly and you can't really install all the tools you need. We've also had serious troubles with performance in some cases (presumably caused by other users on the same machine).

Thanks to all the excellent resources on server management (like serversforhackers.com and sysadmincasts.com) and tools to provision them (like Forge) I feel confident enough to administer my own boxes. A little over a year ago all new projects at Spatie are hosted on DigitalOcean. We have multiple droplets running and haven't run into any of the problems we faced with the old school hosting providers.

Read more

Sharing controller logic with traits

We've moved our logic into a trait, a trait can be shared between many controllers without inheritance and it's more reasonable to do things with views and redirects here (though still not ideal). This in my eyes is the best solution to the problem, it's what traits are good for and it's quite convenient.
http://tech.graze.com/2015/04/14/sharing-controller-logic-with-traits-in-php/

The article provides a good overview of how the people at Graze came to this solution.

Read more

Comparing the PHP 7 and Hack Type Systems

After writing a couple small programs in Hack I've realized that it's not types themselves that make writing Hack enjoyable: it's the tight feedback loop Hack creates between the machine and myself. Integrating the Hack type checker into my editor means that my entire codebase is analyzed in a split second as soon as I save a file. This immediately surfaces any dumb, or subtle mistakes I made. I find myself writing code fearlessly: when I forget what a function returns, I just write code that calls it with what I think it returns. If I'm wrong, the type checker will tell me immediately. I can fix it quickly, and move on.

PHP has always facilitated a tight feedback loop between the machine and the developer. Save the file, reload the browser, repeat. Hack's type checker makes this even faster. I look forward to being able to build similar tooling on top of PHP 7's strict mode.

http://www.dmiller.io/blog/2015/4/26/comparing-the-php7-and-hack-type-systems

Read more

A medialibrary package for Laravel 5 original

by Freek Van der Herten – 3 minute read

At Spatie all our greenfield projects are powered by custom built CMS based on Laravel 5. An important part of the CMS is the medialibrary-component. It handles how uploaded files are associated with models. My intern and I recently took the time to release our medialibrary as a package on GitHub.…

Read more

Comparing the PHP 7 and Hack Type Systems

After writing a couple small programs in Hack I've realized that it's not types themselves that make writing Hack enjoyable: it's the tight feedback loop Hack creates between the machine and myself. Integrating the Hack type checker into my editor means that my entire codebase is analyzed in a split second as soon as I save a file. This immediately surfaces any dumb, or subtle mistakes I made. I find myself writing code fearlessly: when I forget what a function returns, I just write code that calls it with what I think it returns. If I'm wrong, the type checker will tell me immediately. I can fix it quickly, and move on.
http://www.dmiller.io/blog/2015/4/26/comparing-the-php7-and-hack-type-systems

Read more

PHPeople

Over at the Fortrabbit blog you'll find a great list containing various influencers of the PHP ecosystem.

... we have to have an eye on future trends. So we are monitoring what’s going on in the open source PHP world. It’s fun watching all those interesting projects out there. But it’s not about technology only. You’ll need to know about the people driving the projects to understand what’s going on. What are the visible, vocal & visionary PHPeople up to?

Read more

How many HTTP status codes should your API use?

... it’s important to remember that API design isn’t strictly about the practical implications on client and server software. The audience for an API is the developer who is going to consume it. Per the "principle of least astonishment," developers will have an easier time learning and understanding an API if it follows the same conventions as other APIs they’re familiar with.
https://blogs.dropbox.com/developers/2015/04/how-many-http-status-codes-should-your-api-use/

Read more