Category: PHP
-
A PHP time-lapse: tools and resources for Modern PHP
PHP has come a long way since its humble beginnings as a simple scripting language and Modern PHP has several peculiar traits (see what I did there?) But with a simple Google search along with great material about how to write Modern PHP you will find a lot of outdated blog posts or resources that […]
-
Potential roadmap for multisite
Three plus years later, we’re still finding oddities in old MU code, so it makes sense to bide our time and only undergo renames when they let us shed dead weight. The side effect of keeping the barrier to entry high for multisite is not necessarily a bad one — even three years after merge, […]
-
Sort an array by object attribute in PHP
One of those simple things that I keep forgetting. Suppose you have to sort a set of PHP objects, based on an attribute. To do this, you can implement the __toString method and use the SORT_STRING flag in the sort function: <?php class Car { private $_maker; public function __construct( $maker ) { $this->maker = $maker; […]
-
@return tag for methods returning array of objects
I always wondered how to write the @return tag for methods that return an array of objects. Today I discovered that you have to write: <?php class AnotherClass { /** * @return MyClass[] */ public function getClasses() { // logic here return $array_of_classes; } } You can read the relevant docs here.
-
Update autoloader with Composer
I keep forgetting this: to update an autoloader created with Composer issue this command $ composer dump-autoload
-
Local executable for Composer
Last month I learned this little trick for Composer. If you modify your PATH env variable in this way export PATH="vendor/bin":$PATH when you switch project it will automatically load the local executable for the dependency.
-
How to debug with PHPStorm and PHP builtin server
I was playing with Symfony recently, and I needed to setup debug in PHPStorm using the PHP internal web server. I’ve setup xdebug with PHPStorm in multiple environments, and each time I find a different glitch. Lucky me 🙂 So, I will assume that you have PHP, xdebug, PHPStorm installed. These are the steps: Edit […]
-
The importance of developing in a good environment
No, I’m not talking about that strange smell in your room. This is a story that happened to me a while ago. It was certainly my fault, I could be more cautious, but in the end the net result was positive. First job, first delivery, first meeting to check my work. Imagine: I was awake […]
-
PhpStorm Tips #1 – Automatically declare a class field
Everyone should know how to get the most out of his working tool. To me, it’s the editor I use to code. That’s not the case for many of my fellow programmers, who know just the basic stuff. That’s why I’ve decided to realize these little tips. Here’s the first one, on how to automatically […]
-
The good thing
…after writing a couple of projects that mixed PHP and HTML freely one comes up with the idea that separation of form and content is a Good Thing™