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

Torben Köhn:
PHP Generators – A Guide and Tutorial
Jun 22, 2016 @ 13:45:44

For those that may have heard about generators but aren't too familiar with them or what they do, Torben Köhn has posted a great introduction to them and their functionality.

In my in-depth guide about iterators I talked about what iterators are exactly and how you can use them. At the end I told you that I’ll also write one for generators. Here it is.

First off, if you don’t know what an iterator is and you’d not be able to explain to someone else what it is, you will not have much fun with this because you won’t exactly recognize the use-cases. I suggest you read my iterator-guide first. After this, don’t get scared off by some confusing words used here, I’ll try to clarify every single one.

He breaks up the rest of the post into different sections, each walking you through different aspects of generators:

  • What is a generator?
  • The yield-keyword
  • Iterating a generator
  • Yielding keys
  • Yielding in a loop
  • An infinite generator

He wraps up the post sharing some real use-cases for generators to help you understand them with a bit more practical application (including stacking them, file system handling and co-routines).

tagged: generators tutorial introduction guide beginner

Link: http://tk.talesoft.io/2016/06/06/php-generators-a-guide-and-tutorial/

SitePoint PHP Blog:
Contributing to PHP: How to Fix Bugs in the PHP Core
Apr 12, 2016 @ 10:37:27

On the SitePoint PHP blog Thomas Punt continues his series about how you can contribute back to the PHP language. In his previous post he talked about contributing to the PHP manual. In this latest part of the series he moves into something with a bit more complexity: contributing to the core of the language itself.

Previously, we covered contributing to PHP’s documentation. Now, we will be covering how to get involved with PHP’s core. To do this, we will be looking at the workflow for fixing a simple bug in the core.

Since submitting new features to PHP has already been explained pretty well, we will not be covering that here. Also, this article does not seek to teach PHP’s internals. For more information on that, please see my previous posts on adding features to PHP.

In this article he assumes you at least already have a working knowledge of the PHP source and how to locate/update code and execute it. He focuses instead on the bugfix process and workflow needed to:

  • find a bug to fix
  • create a test to reproduce the issue
  • use a debugger to find the exact spot where the problem is
  • and create a simple fix

In this case it's a pretty simple issue to correct, but there are much more complex things that would require more work than just a simple "if" check. This guide can help you get started on the correct workflow, however, and be sure you're handling things as the project expects.

tagged: contribute fix bug core language guide workflow test phpt

Link: http://www.sitepoint.com/contributing-to-php-how-to-fix-bugs-in-the-php-core/

Adam Culp:
Setting up step debugging in Zend Studio
Apr 11, 2016 @ 11:52:43

Adam Culp has posted a guide on his site showing you how to set up debugging in Zend Studio, the PHP IDE from Zend. In it he walks you through the setup on both the server and client side to get them working happily together.

Recently I was helping someone set up step debugging in Zend Studio, and had some difficulties. Therefore I decided to create a blog post to remind me later, and perhaps help others get it set up.

I was doing this on an Ubuntu laptop, so while menus may vary slightly the process should be very similar. Also, I did this using a local virtual machine in VirtualBox, but using Bridged networking mode to simulate a remote server. In Zend Studio I had a project created with the Zend Framework Skeleton Application, and created a virtualhost in the virtual environment that mirrored that.

He starts with the server, pointing out that the only thing really needed there is an installed and working version of Xdebug. He then goes through each step in the IDE, complete with screenshots:

  • Configuring the server in the Preferences
  • Testing the connection between the two
  • Enabling debugging on the project
  • Ensuring the server is configured correctly to use debugging when specified

While some of his instructions are more specific to a Zend Server installation, they can still be mostly applied to any kind of system. You can also check the Xdebug documentation for additional help.

tagged: debugging zendstudio guide zendserver configuration testing xdebug

Link: http://www.geekyboy.com/archives/1220

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - CLI Example
Apr 07, 2016 @ 10:43:51

Loïc Faugeron has posted another in his "ultimate guide" series of posts around components in the Symfony framework. In this latest post he gives an example of using the command line component with the Console component.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console. We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory.

Finally we've started to put all this knowledge in practice by creating a "fortune" project with: an endpoint that allows us to submit new fortunes, a page that lists all fortunes. In this article, we're going to continue the "fortune" project by creating a command that prints the last fortune.

He walks through the use of an example repository as a base and shows:

  • the creation of the command class
  • the matching tests to ensure it's working correctly
  • building out the logic to pull in the latest fortunes

They enter the fortunes via the web interface and use the command line to output them as as simple text.

tagged: ultimate developer guide symfony commandline cli example tutorial series

Link: https://gnugat.github.io/2016/04/06/ultimate-symfony-cli-example.html

Scotch.io:
The Ultimate Guide to Sending Email in Laravel
Apr 01, 2016 @ 12:35:21

On the Scotch.io site today there's a new tutorial giving you the ultimate guide to sending emails in Laravel - from choosing your provider out to sending both text and HTML emails (some with attachments).

Sending emails in web applications has become so essential. Marketing, notifications, newsletters, adverts, etc are some of the reasons why we send emails to our clients. I'd say the majority of websites send automated emails at least via a "Contact us" form.

Let's explore the many possible ways to send emails in a Laravel application.

They start off with a brief look at three different services you can set up out of the box with Laravel: Mailgun (for regular sending), Mailtrap (for debugging) and Mandrill (for bulk emails). They show you how to configure each service in Laravel and setting one of them up as the default. The tutorial then gets into sending the actual emails through a simple EmailController::send endpoint. They show the code to set up the Mail. They show examples of what the resulting emails look like and how they show up in the related mail services. There's also instructions on attaching files, using queues to optimize email sending and a "bonus" about sending bulk emails with MailChimp.

tagged: send email laravel tutorial ultimate guide mailchimp mailtrap mailgun

Link: https://scotch.io/tutorials/ultimate-guide-on-sending-email-in-laravel

SitePoint PHP Blog:
A Comprehensive Guide to Using Cronjobs
Mar 31, 2016 @ 12:18:47

If you've ever wanted to learn about cron jobs, how to set them up and what kind of functionality they provide then the SitePoint PHP blog has the post for you. In this comprehensive guide to cron you learn about these topics and more.

There are times when there’s a need for running a group of tasks automatically at certain times in the future. These tasks are usually administrative, but could be anything – from making database backups to downloading emails when everyone is asleep. [...] This article is an in-depth walkthrough of this program, and a reboot of this ancient, but still surprisingly relevant post.

They start by going through some of the basic terminology and syntax, where the cron files live and what a typical file format looks like. Also included are instructions on:

  • how to edit the cron correctly (crontab)
  • the structure of each cron entry
  • how to have it run at the time you want
  • editing another user's crontab
  • cron permissions
  • redirecting output

They also talk about executing PHP in a cron job, how to prevent overlaps with a "lock" file . There's also a mention of Anacron as a replacement for cron and a few helpful hints to help you debug when things go wrong.

tagged: cron cronjob tutorial comprehensive guide configuration execution

Link: http://www.sitepoint.com/a-comprehensive-crash-course-into-cronjobs/

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Web Example
Mar 30, 2016 @ 10:50:17

In a previous post Loïc Faugeron showed you how to take all of the components he'd talked about so far and make a simple API endpoint. In this latest post he takes the same functionality and makes a web-facing example instead.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console. We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory.

Finally we've started to put all this knowledge in practice by creating a "fortune" project with an endpoint that allows us to submit new fortunes.

In this article, we're going to continue the "fortune" project by creating a page that lists all fortunes.

He goes through a similar process as before, but with a few changes to make it output a web page instead of API (JSON) results:

  • Create the Controller
  • Configure related routing
  • Create the logic to list all current fortunes
  • Putting the "wiring" in place to connect it to the database
  • Creating the view to output a simple page with the fortune list

It's that last step that's different, resulting in a simple (non-templated) page being output with HTML markup. He then refactors this to use Twig as the templating output layer, removing the output generation from the application logic.

tagged: ultimate developer guide symfony web example component combine tutorial

Link: https://gnugat.github.io/2016/03/30/ultimate-symfony-web-example.html

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - API Example
Mar 25, 2016 @ 10:31:09

Loïc Faugeron has posted another article in his "Ultimate Developer Guide to Symfony" series today. In this new article he shares an API example making use of the knowledge gained from the other articles to create a simple project.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console.

We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory. In this article, we're going to put all this knowledge in practice by creating a "fortune" project with an endpoint that allows us to submit new fortunes.

He starts by creating the project (via Composer's create-project command), sets up a basic routing configuration and installs PHPUnit for testing. He then shows the creation of the controller - test first - to handle the "fortune" endpoint requests. He then comes back in and adds in some logic around the submission including matching tests. This is then refactored further to use Doctrine to insert the contents into a database. Additional code is provided showing how to "wire it all together" and create the database structure. The entire post takes the TDD approach so tests for all submission functionality are included.

tagged: ultimate developer guide symfony api example component combine tutorial

Link: https://gnugat.github.io/2016/03/24/ultimate-symfony-api-example.html

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Skeleton
Mar 17, 2016 @ 10:24:39

Loïc Faugeron has posted another in his series of "Ultimate Developer Guides" for a component of the Symfony framework. In the latest part of the series, he looks at the Skeleton component.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console. We've also seen how HttpKernel enabled reusable code with Bundles.

In this article, we're going to have a closer look at how to organise our applications directory tree.

He shows how to create a new project with the "empty edition", a skeleton for creating a basic Symfony framework with some of the basic boilerplate already in place. He shows the resulting directory tree and creates a new AppBundle for his new development. Initially he put the bundle under the main directory so he then shows how to decouple this and move bundles and libraries out into a src/ directory outside of the main application directory in the skeleton.

tagged: symfony ultimate developer guide tutorial skeleton edition empty bundle library decouple

Link: https://gnugat.github.io/2016/03/16/ultimate-symfony-skeleton.html

SitePoint PHP Blog:
Running an Elastic LAMP Stack on AWS
Mar 15, 2016 @ 11:54:38

The SitePoint PHP blog has posted a tutorial from Daniel Berman giving you a step by step guide to setting up an Elastic LAMP stack on AWS, the Amazon Web Services platform using Zend Server.

This article introduces what is probably one of the simplest ways of setting up and running an elastic LAMP stack on the cloud – using Zend Server on AWS.

More specifically, the workflow described here includes launching a pre-configured AWS CloudFormation template that sets up all the components of a LAMP stack: Zend Server’s certified PHP stack plus all of Zend Server’s add-on features (including Z-Ray), a MySQL database, a Zend Server elastic group consisting of additional Zend Server instances, an elastic load balancer, and other pre-configured security definitions. This article is perfect for those contemplating moving their production environment to the cloud or those who already have one set up on AWS.

He starts with some of the basics: what Zend Server is and what role CloudFormation plays in the deployment process. The rest of the tutorial is broken up into several steps of the setup and deployment process:

  • Step 1: Launching the stack
  • Step 2: Managing the stack
  • Step 3: Deploying an application
  • Step 4: Monitoring the stack

They include screenshots of the web-based interfaces you'll use to complete each of these steps, giving you a great visual guide to where you should be and what things should look like. In the end you'll have a simple application, running in AWS on Zend Server you can easily monitor and configure.

tagged: zendserver tutorial elastic aws amazon webservices setup configure guide

Link: http://www.sitepoint.com/running-an-elastic-lamp-stack-on-aws/