Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Toptal.com:
PHP Frameworks: Choosing Between Symfony and Laravel
Mar 02, 2017 @ 11:26:17

On the TopTal.com blog Karin Sakhibgareev shares some of his thoughts around picking the right framework for your project. More specifically he focuses on the selection between two popular options: Symfony or Laravel.

Today, when starting a new project, one of the key decisions is to pick the right framework. It’s become hard to imagine building a complex web application from scratch nowadays without one.

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, I am going to compare these two frameworks and show you how to implement simple, everyday features with each. This way, you can compare the code of real-life examples side by side.

He starts with a brief history of each project (Symfony and Laravel) and quick guides to getting them installed. He then configures them with a few basic options (database connection, security details, etc) and compares the setup processes against each other. The reminder of the post follows the same pattern covering:

  • routing setup and configuration
  • templating (Blade vs Twig)
  • dependency injection
  • database usage via ORMs
  • event dispatching/middleware

The post ends with a sort of "real world" application of each framework, showing what it would take to create a simple REST API. He finishes with his thoughts about the "winner" of the comparison...but suggests that it's more about the right tool for the right job than one framework that does it all.

tagged: toptal framework symfony laravel tutorial comparison

Link: https://www.toptal.com/php/choosing-between-symfony-and-laravel-frameworks

Toptal.com:
The Ultimate Guide to Building a WordPress Plugin
Dec 23, 2016 @ 12:07:41

For those newer to the world of WordPress, you might only be casually familiar with WordPress plugins and their use. You might have only installed them and used them before but have you wondered what it would take to make your own? In this new tutorial from Toptal.com Ratko Solaja gives you a "ultimate guide" to getting started down the road of custom WordPress plugin development.

Plugins are a vital part of WordPress websites that need specific functionalities. While the official WordPress repository has more than 45,000 plugins from you to choose from, many of these plugins miss the mark.

Just because a plugin is in the repository doesn’t mean it won’t hinder its performance or compromise its security. So what can you do? Well, you can build your own.

He starts with the planning stages of his example plugin (a real-world project helps when learning new things) - one that allows users to save content for later reading. He outlines the goals of the settings screen, how saving will work, messages to the user and what the "saved" screen will do. He recommends starting with a boilerplate plugin and working from there. He then goes through each step of the development process:

  • Handle activation and deactivation
  • Create a plugin settings page
  • Create the plugin functionality
  • Make the plugin modular
  • Generate translation files

The end result is a complete plugin with both the required frontend and backend functionality to make the "save content" feature work. All code is provided and plenty of links to more information and other resources are sprinkled throughout the article.

tagged: toptal wordpress plugin guide tutorial content example

Link: https://www.toptal.com/wordpress/ultimate-guide-building-wordpress-plugin

Toptal.com:
Data Encoding: A Guide to UTF-8 for PHP and MySQL
Jan 28, 2016 @ 13:22:56

The Toptal.com blog has posted a guide to data encoding in PHP and MySQL looking specifically at the use of UTF-8 and related handling. They talk about some of the updates you'll need to make to configurations, code and the MySQL settings to fully support this character set.

As a MySQL or PHP developer, 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 data encoding 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 (and with thanks, in part, to information discovered here and here along the way).

They start with the changes on the PHP side, updating the INI settings to make UTF-8 the default character set and which functions you'll need to update and replace. With those changes out of the way they move to the MySQL side, changing up settings in the my.cnf file and a few other things to consider on the database side (including that the MySQL support for UTF-8 is only a partial character set).

tagged: toptal data encoding mysql utf8 update configuration code

Link: http://www.toptal.com/php/a-utf-8-primer-for-php-and-mysql