PHP Posts

The Toptal Engineering Blog is a hub for in-depth development tutorials and new technology announcements created by professional software engineers in the Toptal network.
Kevin Bloch
Haxe: Cross-platform Development's Best-kept Secret

The modern, cross-platform programming language Haxe is well-known in some circles, yet many developers have never heard of it. Since it first appeared in 2005, it’s been battle-tested by its loyal—if rather quiet—following.

In this article, Toptal Freelance Software Engineer Kevin Bloch explores the Haxe ecosystem and how to transpile some sample code.

Continue reading →
Rodrigo Donini
How to Create Exclusive Custom Taxonomies in WordPress

In WordPress, taxonomies allow you to flexibly organize your content in categories with tags and more. However, when defining custom taxonomies, you may not get the desired behavior out of the box.

In this article, Toptal Freelance Software Engineer Rodrigo Donini shows how exclusive custom taxonomies can be implemented in WordPress for strict categorization of posts.

Continue reading →
Agustin Villalba
Introduction to Objects and References in PHP Memory

In this article, I will talk about how object and variable references are controlled in memory, since this is an issue that can generate discussion and differing opinions. One question to ponder is: “By default, are objects passed by reference or by copy in PHP?” I’m going to talk first about what references aren’t in PHP; secondly, I’ll discuss what they are, and finally, I will examine how the garbage collector works in PHP.

Continue reading →
André Castelo
Laravel API Tutorial: How to Build and Test a RESTful API

Laravel is a PHP framework developed with developer productivity in mind. Written and maintained by Taylor Otwell, the framework is very opinionated and strives to save developer time by favoring convention over configuration. The framework also aims to evolve with the web and has already incorporated several new features and ideas in the web development world—such as job queues, API authentication out of the box, real-time communication, and much more.

In this article, we’ll explore the ways you can build—and test—a robust API using Laravel. We’ll be using Laravel 5.4, and all of the code is available for reference on GitHub.

Continue reading →
Brad Peabody
Server-side I/O Performance: Node vs. PHP vs. Java vs. Go

Understanding the Input/Output (I/O) model of your application can mean the difference between an application that deals with the load it is subjected to, and one that crumples in the face of real-world uses cases. Perhaps while your application is small and does not serve high loads, it may matter far less. But as your application’s traffic load increases, working with the wrong I/O model can get you into a world of hurt.

Continue reading →
Karim Sakhibgareev
PHP Frameworks: Choosing Between Symfony and Laravel

Many popular languages for web development have their ‘default’ framework, such as Ruby on Rails for Ruby, or Django for Python. However, PHP has no such single default and has multiple popular options to choose from.

In this article, Toptal Freelance Developer Karim Sakhibgareev compares the two most popular PHP frameworks, Symfony and Laravel, explores their features, and establishes guidelines for how PHP developers should choose between them.

Continue reading →
Brian Coords
WordPress REST API: The Next Generation CMS Feature

For a while, WordPress seemed to had fallen behind. As the web became more reliant on JavaScript to create immersive, interactive experiences, it became increasingly clear that WordPress needed to offer new ways for users and developers to interact with its content.

In this post, Toptal Freelance Developer Brian Coords explores the amazing new features of WordPress’s REST API, showing why WordPress is still on the cutting edge of web development.

Continue reading →
Igor Santos
How to Build a Multilingual App: A Demo With PHP and Gettext

Making your website or web app available to a wider audience often requires it to be available in multiple languages. For non-English projects, you can increase your audience by releasing it in English as well as your native language. Internationalizing and localizing your project, however, becomes a much easier process if you start during its infancy.

In this article, Toptal Software Engineer Igor Gomes dos Santos shows us how to leverage simple tools, like Gettext and Poedit, to internationalize and localize a PHP project.

Continue reading →
Donald Mudenge
Don't Hate WordPress: 5 Common Biases Debunked

Today, WordPress covers more than 50 percent of website shares and serves nearly 60 million websites worldwide. Its popularity has resulted in many misconceptions that have grown and spread like a forest fire, and have made people stay away from WordPress.

In this post, Toptal Software Engineer Donald Mudenge explains the five most common WordPress taboos and myths, clarifies them, and offers solutions on how to overcome them.

Continue reading →
Ratko Solaja
The Ultimate Guide to Building a WordPress Plugin

WordPress plugins can be both a blessing and a curse. With more than 45,000 plugins available in its official repository, WordPress users can customize their website to their heart’s content. However, not all plugins follow the standards necessary to keep the platform performant and secure while also delivering a solid user experience.

In this tutorial, Toptal Software Engineer Ratko Solaja shows us how to build a robust WordPress plugin, following all the necessary best practices.

Continue reading →
Martín Di Felice
The Advanced Guide to Optimizing WordPress Performance

WordPress, one of the most popular publishing platforms, has stood the test of time and now powers a significant portion of the web. Sadly, its reputation is plagued by claims of poor performance and complexity with scaling. However, the root causes of such performance issues are often bad code and poorly implemented plugins and themes.

In this post, Toptal Software Engineer Martín Di Felice shares tips and tricks for WordPress developers who want to build better plugins and themes and destroy the notion that WordPress is a slow platform.

Continue reading →
Andrew Hughes
Use Magento If You're Serious About eCommerce

You’ve heard that Magento is the eCommerce platform to use if you’re serious about your business – and you’re serious about your business – so you’ve decided on Magento. But do you know what you’re getting into?

In this post, Toptal Software Engineer Andrew Hughes walks us through the difference between WordPress WooCommerce and Magento. While Magento is the expert’s eCommerce platform of choice, it’s not always the right solution, depending on your client.

Continue reading →
Andrew Schultz
The 10 Most Common Mistakes That WordPress Developers Make

WordPress is easily the most powerful open source blogging and content management system available online today. As WordPress is easy enough to set up and has a user-friendly approach, many developers are often underestimating it and so make mistakes in development.

In this article, Toptal Freelance Software Engineer Andrew Schultz outlines the ten most common mistakes that WordPress developers should be aware of for future projects.

Continue reading →
Vasily Koval
Jumpstart Your PHP Testing with Codeception

Would you like to test your PHP code like a boss? Do you feel that basic unit tests and PHPUnit just don’t cut it anymore? If your answer to both questions is yes, you might want to try Codeception, a mature and well-documented testing framework designed to outperform PHPUnit and Behat.

In this post, Toptal Freelance Software Engineer Vasily Koval describes how he came to take the plunge and start using Codeception, and he explains why you should check out Codeception for your PHP testing needs.

Continue reading →
Daniel Gheorghe
Handling Intensive Tasks with Laravel

When dealing with time consuming, resource intensive tasks, most PHP developers are tempted to choose the “quick hack route”. We’ve all used “ini_set(‘max_execution_time’, HUGE_INT);” before, but it doesn’t have to be this way.

In today’s tutorial, PHP developer Daniel Gheorghe demonstrates how an application’s user experience may be improved by separating long-running tasks from the main request flow using Laravel.

Continue reading →
Vilson Duka
Introduction To PHP 7: What's New And What's Gone

If you haven’t been working with PHP lately, you might wonder what happened to PHP 6. Why the skip from PHP 5 to PHP 7? Well, long story short, PHP 6 was a failure. To avoid confusion, the new version was renamed PHP 7.

PHP 7 introduces a number of new features, while at the same time dropping depreciated SAPIs and extensions. As a result, it tends to outperform PHP 5.x by a wide margin. Some compatibility issues could pose a problem, but most developers have nothing to worry about.

In this post, Toptal Freelance Software Engineer Vilson Duka explains what makes PHP 7 different, and why it’s time to make the switch.

Continue reading →
Artem Galtsev
Building an IMAP Email Client with PHP

Developers sometimes run into tasks that require access to email mailboxes. In most cases, this is done using the Internet Message Access Protocol, or IMAP. As a PHP developer, I first turned to PHP’s built in IMAP library, but this library is buggy and impossible to debug or modify. So today we will create a working IMAP email client from the ground up using PHP. We will also see how to use Gmail’s special commands.

Continue reading →
Krzysztof Ożóg
Online Video with Wowza and Amazon Elastic Transcoder

Performance and data interoperability are critical to the success of any web application. For web apps that need to support video processing – which is inherently compute- and I/O-intensive – these challenges are particularly acute. In this post, I describe some of my experience successfully incorporating video capabilities into a PHP-based web app, leveraging open source technologies and cloud-based services to the greatest extent possible.

Continue reading →
Arminas Zukauskas
Building REST API for Legacy PHP Projects

Every once in a while PHP developers are charged with tasks that require them to extend the functionalities of legacy projects, a task that often includes building REST APIs. Building a REST API for PHP-based projects is challenging, but in the absence of proper frameworks and tools, it can also be a particularly difficult goal to get right. In this article, Toptal engineer Arminas Zukauskas shares his advice, with sample code, on how to build a modern structured REST API around existing legacy PHP projects.

Continue reading →
Ilya Sanosyan
Getting the Most Out of Your PHP Log Files: A Practical Guide

Log files may very well be one of the most underestimated and underutilized tools at a developer’s disposal. Beyond their value for debugging, with a bit of creativity and forethought, logs files can be leveraged to serve as a valuable source of usage information and analytics. In this article, In this article, Toptal engineer Ilya Sanosyan provides a practical guide to maximizing the value we get from our logs.

Continue reading →
Oleksii Rytov
Why I Decided To Embrace Laravel

Laravel designers didn’t spend too much time reinventing the wheel. A lot of solutions and practices are transferred from other frameworks.

The decision to embrace a new PHP framework should not be taken lightly, so let’s examine why considering Laravel may be worth your time and effort. Toptal freelance software engineer Alex Rytov explains what made him take the plunge and why he believes Laravel has a bright future.

Continue reading →
Ilya Sanosyan
Buggy PHP Code: The 10 Most Common Mistakes PHP Developers Make

PHP makes it relatively easy to build a web-based system, which is much of the reason for its popularity. But its ease of use notwithstanding, PHP has evolved into quite a sophisticated language, with many nuances and subtleties that can bite developers, leading to hours of hair-pulling debugging. This article highlights ten of the more common mistakes that PHP developers need to beware of.

Continue reading →
Francisco Clariá
A Guide to UTF-8 Encoding in PHP and MySQL

Once you step beyond the comfortable confines of English-only character sets, you quickly find yourself entangled in the wonderfully wacky world of UTF-8.

Indeed, navigating through UTF-8 related issues can be a frustrating and hair-pulling experience. This post provides a concise cookbook for addressing these issues when working with PHP and MySQL in particular, based on practical experience and lessons learned.

Continue reading →
Radan Skoric
Great Developers Know When and How To Refactor Rails Code

If it ain’t broke, don’t fix it.

It’s a well known phrase, but as we know, most of the human technological progress was made by people who decided to fix what isn’t broken. Especially in the software industry one could argue that most of what we do is fixing what isn’t broken.

Fixing functionality, improving the UI, improving speed and memory efficiency, adding features: these are all activities for which it is easy to see if they are worth doing, and then we argue for or against spending our time on them. However, there is an activity, which for the most part falls into a gray area: refactoring, and especially large scale refactoring.

Continue reading →
Ryan Wilcox
How to Work Remotely and Still Be the Best

Starting a new remote gig, be it a contract project or a full-time job, can be a little intimidating if you’re used to going into an office day after day.

But this style of employment is growing in popularity, with some very notable companies lending it their endorsements.

I’ve worked remotely for years now on projects of various scales and durations. With this post, I hope to enumerate some of the best practices that I’ve picked up for working in a variety of situations. The advice here ranges from specific recommendations for software and hardware, to tips for hitting your team’s deadlines.

Continue reading →
Alejandro Rigatuso
Growing Growth: Perform Your Own Cohort Analysis with This Open Source Code

But this isn’t just another article about cohort analysis. If you already know the importance of the topic and want to skip the introduction, you can jump to the simulator, where you can either simulate startup growth based on retention, churn, and a number of other factors, or analyze your own PayPal logs with the code I’ve open sourced.

If, however, you don’t realize that these are some of the most important metrics around–continue reading.

Continue reading →
Francisco Clariá
How I Made a Fully-Functional Arduino Weather Station

I live in Córdoba, Argentina, approximately 130 kilometers (~80 miles) away from the lake where I kitesurf. Thats roughly a two-hour drive, which I can deal with. But I cant deal with the fact that weather forecasts are inaccurate. And where I live, good wind conditions last just a couple of hours. The last thing you want to do is clear up your Monday schedule to go kitesurfing and find yourself cursing the gods on a windless lake after two hours of driving.

I needed to know the wind conditions of my favorite kitesurfing spot—in real time. So I decided to build my own weather station.

Continue reading →
Cameron Barr
Engineering Internals of a RAD Framework... as a PHP Developer with Nooku

Everyone has their own set of tools. As a PHP developer, one of my favorites is a Rapid Application Development framework called “Nooku”. In the words of the development group: “Nooku is more of a web development toolkit than a framework”

In case you are not familiar with it, have a look. It’s an open source project that makes heavy use of industry accepted design patterns to produce highly componentized applications that are easily extensible and reusable (initially created by one of the lead Joomla developers). Out of the box, Nooku gives you a great deal to help get projects off the ground faster. A small, but strong sample:

Continue reading →