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

DaedTech Blog:
Avoid these Things When Logging from Your Application
Dec 06, 2016 @ 11:53:48

On the DaedTech blog Erik Dietrich has written up a list of a few things he suggests avoiding when using logging functionality in your application. The suggestions range from the actual contents of the message out to some logging best practices.

It seems almost strange to talk about avoiding things while logging. After all, logging is your last line of defense or your salvation in many cases. [...] Well, it turns out that, while logging may be a highly inclusive activity in terms of what should be included, there are ways to create problems. You want to be liberal in terms of what you log, but judicious and wise in terms of how you log it. You don’t want to indulge in a feckless free-for-all when it comes to the calls you make to your application’s logger.

So what are these problems, and how to avoid them? Let’s take a look at some things that can come back to bite you.

He points out the following (common) bad practices he has seen during his time developing:

  • Forgetting Context
  • Cryptic Codes
  • Spamming the Log File
  • Unsafe Logging Calls
  • Mixing Application Logic with Logging

He ends the post with a suggestion of "sensible logging" - capturing as much meaningful information as possible while not overdoing it. Logs can be a powerful ally when hunting down an issue or trying to provide documentation of a security issue. Log wisely, log on purpose.

tagged: logging practices recommendation avoid list

Link: http://www.daedtech.com/avoid-things-logging-application/

SitePoint PHP Blog:
9 Hot Tips to Enhance Your Spark Experience
Sep 29, 2016 @ 10:59:26

The SitePoint PHP blog has posted an article for the Laravel Spark users out there, sharing their top nine tips for getting the most out of the popular "boilerplate" tool.

A while ago, I wrote about a product I wanted to build, to allow easy remote backups for Pagekit sites. I’ve been working on it (periodically) since then, and have come across a few interesting bits of advice.

I decided to use Laravel Spark as the foundation for the product, and I thought it would be helpful to share the advice. Whether you’re just starting your Spark app, or are in maintenance mode, I think you’ll find some of these tips useful!

His tips cover a wide range of the product's features:

  • You Don’t Have to Keep All the Base Files
  • Use Simple Repositories
  • Don’t use caret (^) Laravel dependencies
  • Host on Forge
  • Re-Arrange Middleware

Each of these comes with a description and, where appropriate, a bit of code to help clarify the point.

If you’re on the fence about trying Spark, I can recommend it. It’s given my product a head-start it wouldn’t have had otherwise. Hopefully these tips will save you even more time.
tagged: tips top9 laravel spark usage recommendation example

Link: https://www.sitepoint.com/9-hot-laravel-spark-tips/

Intracto Blog:
How to save a kitten by writing clean code
Jun 03, 2016 @ 12:52:50

On the Intracto blog there's a new post from Joeri Timmermans talking about writing clean code with some good suggestions you can easily incorporate into your current processes.

So you came here to save a kitten? That's wonderful, but the real reason we're both here is to talk about clean code. In this blog post I'll be sharing some of my personal experiences and tips. But before we dive into the tips and tricks part, let's talk about what we, as developers, do and why we do it.

He touches on several topics including:

  • Best vs Fastest
  • Reading vs Writing
  • File and Folder Organization
  • Naming [conventions and clarity]

He also makes the recommendation to "return often", keep things DRY and makes a few recommendations of PHP-specific tools that can help.

tagged: clean code recommendation process development opinion

Link: http://blog.intracto.com/how-to-save-a-kitten-by-writing-clean-code

SitePoint PHP Blog:
PredictionIO and Lumen: Building a Movie Recommendation App (Part 2)
Apr 06, 2016 @ 14:30:42

The SitePoint PHP blog has posted the next part in their series about using Predictive.IO and Lumen to create a simple movie recommendation application (part one is here). In this second part of the series they build on the environment created in the previous article and start developing the actual application.

In the intro, we covered the basics of PredictionIO and installed its dependencies. In this part, we’re going to build the movie recommendation app.

The tutorial starts with a brief configuration section to ensure you have your API keys configured correctly. Then it gets into the code:

  • Pulling the data from the Movie DB API
  • Creating the endpoint to perform the endpoint
  • Picking random movies to show the user and recording their reactions (like/dislike)
  • Creating the endpoint to recommend movies

Finally they share the configuration to set up the application deployment and train it with some example content you provide through some basic interactions. Finally they help you set up a cron job to train and redeploy the application every five minutes with the latest interaction information.

tagged: tutorial predictionio series part2 movie recommendation implement application

Link: http://www.sitepoint.com/predictionio-and-lumen-building-a-movie-recommendation-app/

SitePoint PHP Blog:
PredictionIO: Bootstrapping a Movie Recommendation App
Apr 05, 2016 @ 11:22:11

On the SitePoint PHP blog they've posted a tutorial showing you how to use the Prediction.IO server to create a movie recommendation application. Prediction.io is "an open source Machine Learning Server built on top of state-of-the-art open source stack for developers and data scientists create predictive engines for any machine learning task".

In this tutorial, I’m going to walk you through PredictionIO, an open-source machine learning server, which allows you to create applications that could do the following: recommend items (e.g. movies, products, food), predict user behavior, identify item similarity and rank items.

You can pretty much build any machine learning application with ease using PredictionIO. You don’t have to deal with numbers and algorithms and you can just concentrate on building the app itself.

The tutorial, the first part of a series, refreshes some older instructions for getting the Prediction.IO system up and running. He walks you through the creation of an AWS instance for the server a few different ways (Vagrant, Docker, etc). He then talks about the use of the Movie API from MovieDB and the two parts of the application that will be implemented on top of it: a learning phase and a recommendation phase. They show how to use Prediction.io to create the recommendation engine and make the new application on top of it. He helps you install some dependencies to use in the PHP side of the application and briefly explains what they're for.

This wraps up part one of the series. In the second part he starts putting this all to use and creates the PHP functionality to lay on top of the machine learning engine and handle learning and recommendations for users.

tagged: predictionio machinelearning server tutorial movie recommendation application part1 series

Link: http://www.sitepoint.com/predictionio-bootstrapping-a-movie-recommendation-app/

Developer Drive:
Looming PHP 7 and its effect on WordPress
Nov 26, 2015 @ 11:54:15

On the Developer Drive site they've posted an article for all of the WordPress users (and other curious folks) about the impact PHP 7 will have on the current WordPress system.

It’s no big secret now that PHP 7 is just on the horizon, and with that development comes questions on how it affects sites that run on WordPress. PHP 7 is a massive update to the server-side web development language called PHP, yet it’s also going to have an impact on any PHP-powered CMS like Drupal, Joomla and Magento.

They go through some of the major changes in PHP 7 and talk briefly about what kind of effects they'll have on those running this popular CMS including:

  • Performance upgrades
  • New and improved operators
  • Continuous 64-bit support
  • Anonymous class support

They recommend that you keep an eye out for messages from your host that they might be upgrading, backing up your site to prevent loss and update your plugins/themes prior to any PHP 7 switch over.

tagged: php7 wordpress features update recommendation hosting

Link: http://www.developerdrive.com/2015/11/looming-php-7-and-its-effect-on-wordpress/

Kinsta Blog:
10 Things Not To Do In PHP 7
Nov 11, 2015 @ 09:53:36

On Kinsta.com Daniel Pataki has posted a list of seven things not to do in PHP 7 when it's finally released. It's no secret that there's a lot of new functionality coming with this new version but that also potentially means some bad practices coming along with them.

I’ve already shared some of the upcoming features of PHP 7, in this article I thought I’d take a look at some of the bad patterns we should stop using as we switch to the lightning fast PHP 7.

Among the things on his list are suggestions like:

  • Do Not Use mysql_ Functions (removed from core)
  • Do Not Use PHP Close Tags At The End Of A file
  • Do Not Perform Queries In A Loop
  • Do Not Trust User Input

Some of the suggestions do have a direct relation to what PHP 7 has to offer but most of them are just good practices to follow during your development work. Quite a few good tips in there, especially if you're relatively new to the language and want to start with PHP 7 and go.

tagged: php7 top10 opinion development practice habits recommendation

Link: https://kinsta.com/blog/10-things-not-to-do-in-php-7/

ThePHP.cc:
How to Validate Data
Nov 10, 2015 @ 10:18:52

In this post to thePHP.cc site Sebastian Bergmann looks at validation data, both in the sense of user input and the contents of objects you're application is currently working with.

Validating data seems to be one of the most important tasks of an application. After all, you cannot trust data from external sources. So let us have a look at how to efficiently implement data validation.

He gives an example of a user profile with requirements on the data it should contain. He focuses on the email address property as it's one of the easier options to validate (or is it). He walks through the usual progression from controller injection to setter injection of the value but wonders when the validation should happen to keep the Profile object from becoming invalid. He points out that simply having a validate method perform the checks isn't enough as it may not always be called correctly, leading to potentially invalid objects. Instead he recommends an alternative - using a validator object/tool in the setters of your object instance as the values are set. This prevents the object from getting into an unknown state and provides immediate feedback to the developer when something's wrong.

tagged: data validation object recommendation setter business rules

Link: https://thephp.cc/news/2015/11/how-to-validate-data

Source Blog:
Good Code Runs on Good Communication
Sep 18, 2015 @ 11:10:27

On the Source blog there's a great post that reinforces something that all developers should keep in mind when developing their applications: good code runs on good communication. "Tech language" barriers can make this difficult, but this post gives you a few suggestions on places to start improving.

When I started the interactive team at the Sun Sentinel in 2013, I thought the biggest challenge would be the code. I was wrong. [...] It wasn’t always easy. When you need someone on your side, but they don’t speak the same tech language, it can be very difficult. Investing (not necessarily financially, but emotionally and mentally) in creating a space where teams can work better together is key. Here are some strategies for overcoming the language barrier to make collaboration smoother.

They recommend things like:

  • having face-to-face conversations to work out the best solutions
  • avoiding assumptions about skill levels
  • pausing to check and ensure everyone understands the current state of conversation
  • agreeing on common terms and naming

Finally, they make a recommendation that could make some of the developers out their cringe a bit: "document the madness". As they point out, having good documentation of not only the result of the work but also the process along the way can be crucial for future work and others not directly involved in the process to review.

tagged: good code communication opinion recommendation language conversation

Link: https://source.opennews.org/en-US/articles/code-runs-communication/

NetTuts.com:
When You're Hacked in WordPress: Staying Safe Later On
Feb 20, 2015 @ 14:19:00

NetTuts.com has posted the second part in their "When You're Hacked - WordPress" tutorial series today with this new article showing you how to stay safe once you've recovered from the initial attack.

n the first part of this series, we went through what to do when your website gets hacked. In this second part, we're going to learn about staying safe and being able to act quickly when another unpleasant incident happens.

They start by answering the overarching question everyone wants to know about WordPress (as it relates to security) - "is it safe?" They follow this with some recommendations to help keep your install safe including:

  • Staying Up to Date
  • Using Safe Plugins & Themes
  • Using a Security-Related WordPress Plugin

Check out the rest of the article for the full list and a quick summary of each, some with links to the actual tools and plugins to help you protect your installation.

tagged: wordpress hack stay safe tutorial series part2 recommendation

Link: http://code.tutsplus.com/tutorials/when-youre-hacked-in-wordpress-staying-safe-later-on--cms-22748