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

Laravel News:
Easy Image Processing in Laravel with Glide
Jan 30, 2015 @ 10:06:41

On the Laravel News site there's a new post sharing a video tutorial of how to use the Glide image handling library with your Laravel-based application.

Glide is a new package by Jonathan Reinink which is an on-demand image manipulation library. In this video he shows you how to set it up and the basic usage in Laravel 5.

In the tutorial Jonathan walks you through an introduction to the library and how it wraps around the Intervention image handling. He creates a basic application that, when an image endpoint is called, output the image with any given configuration options (like height and width). Glide is one of many packages making up The PHP League.

tagged: laravel image processing glide library thephpleague screencast video

Link: https://laravel-news.com/2015/01/using-glide-laravel/

SitePoint PHP Blog:
Building and Processing Forms in Symfony 2
Jun 06, 2014 @ 13:45:07

The SitePoint PHP blog has a new tutorial posted from author Daniel Sipos about form handling in Symfony2. More specifically, about creating them and handling the results from their submission. This is an introduction to the topic and gets into two examples, one focusing on a view implementation and the other using the form builder.

In this tutorial we will look at two examples of using forms in Symfony 2. In the the first, we will place form elements straight in the View file and then handle the form processing manually in the controller. In the second, we’ll use the Symfony form system to declare forms in an object oriented way and have Symfony process and persist the values. We will be working on a simple installation of the Symfony framework.As you may know, it comes with a default bundle called AcmeDemoBundle and we will use that to illustrate working with forms.

In the first example he looks at "non-entity forms" and shows how to create the form from normal HTML elements in the view. The form is just a simple input field and a submit button. He includes the code you'll need to process the form submission too. In the second example he includes an example of how to create the same setup but using the Form Builder instead. It's also links it to a data object, making it simpler to save the submission results.

tagged: symfony2 form processing view builder entity manager tutorial

Link: http://www.sitepoint.com/building-processing-forms-in-symfony-2

Mikko Koppanen:
Working on images asynchronously
Dec 16, 2013 @ 10:45:35

Mikko Koppanen has a new post to his site today about working with images asynchronously - the "offline" processing of things like user uploaded images using a queuing system.

To get my quota on buzzwords for the day we are going to look at using ZeroMQ and Imagick to create a simple asynchronous image processing system. Why asynchronous? First of all, separating the image handling from a interactive PHP scripts allows us to scale the image processing separately from the web heads. [...] Secondly, separating the image processing from a web script can provide more responsive experience to the user. This doesn’t necessarily mean faster, but let’s say in a multiple image upload scenario this method allows the user to do something else on the site while we process the images in the background.

He also includes a "barebones" example of how the system would work. The first Worker script makes the connection to the queue system and sends the data off for handling. The second script does most of the actual work, pulling in the image and using Imagick to create a thumbnail image. Finally he includes an example of the use of the workers in combination to send the image data for processing.

tagged: image asynchronous processing zeromq thumbnail imagick

Link: http://valokuva.org/working-on-images-asynchronously/

Adding Bitcoin Payment Processing to Your Website
Aug 19, 2013 @ 12:38:53

On NetTuts.com there's a new tutorial that shows you how to integrate an up and coming payment method into your site's flow - Bitcoin. The tutorial uses a combination of Javascript and a PHP backend and BIPS as the payment processor.

Bitcoin has definitely started to become more mainstream, and with its global reach and minimal fees, it is a payment method worth considering. In this article, we will take a look at what Bitcoin is, as well as how to start accepting them in your applications. [...] I'm not going to get into the specifics, but essentially each time a transfer of currency takes place, the money is signed with the two parties keys and then hashed, and these transactions are appended to the global log. This allows coins to be publicly traced back, and to see if the money really belongs to someone or not.

He starts off explaining what the whole bitcoin system is based on and some of the common advantages and disadvantages around it. He then gets into the actual application, creating a simple structure using the Slim microframework and a bit of HTML to make a simple payment site. The BIPS processor is used to handle the payment and the Mandrill service to send the confirmation emails. Curl requests are used to call the services, so you'll need it installed as a PHP extension to make their examples work.

tagged: bitcoin processing payment mandrill bips tutorial

Link: http://net.tutsplus.com/tutorials/javascript-ajax/adding-bitcoin-payment-processing-to-your-website

Chris Jones:
Offline Processing in PHP with Advanced Queuing
May 17, 2013 @ 09:49:26

Chris Jones has a new post today showing you how to use Oracle and PHP together to process data offline via the Oracle Streams Advanced Queuing feature.

Offloading slow batch tasks to an external process is a common method of improving website responsiveness. One great way to initiate such background tasks in PHP is to use Oracle Streams Advanced Queuing in a producer-consumer message passing fashion. [...] The following example simulates an application user registration system where the PHP application queues each new user's street address. An external system monitoring the queue can then fetch and process that address. In real life the external system might initiate a snail-mail welcome letter, or do further, slower automated validation on the address.

He includes the SQL needed to create the database and configure the queue system as well as start it up and get it ready for requests. He shows how to push an address into the queue for processing and how to get the results once it has completed in both the SQL and from the oci_* functions in PHP.

tagged: oracle tutorial advanced queue offline processing

Link: https://blogs.oracle.com/opal/entry/offline_processing_in_php_with

Practical Code Refactoring, Part 4 - Efficiency
Nov 01, 2012 @ 11:37:54

PHPMaster.com has posted the latest in their "Practical Code Refactoring" series , this time with a focus on efficiency and how you can refactor your code to help it perform better both in processing power and in resource use.

In part three of this series we dealt with refactoring code for extensibility and discussed logical extensibility, modular design, decoupling, and encapsulation. In this final part of the series, we discuss what the main concerns of efficiency are for your web application and how to refactor for better efficiency.

They talk about some of the things you can do about network bandwidth usage, memory inefficiencies and processing issues (over you doing more work than you need to?). These aren't code examples - every application is different when it comes to this stuff, but it gives you some good questions to ask to fill in the blanks.

tagged: efficiency code refactor series processing resource usage


So You Want to Accept Credit Cards Online?
Jun 14, 2012 @ 09:30:25

On NetTuts.com they're posted a new tutorial about using the Stripe service to accept credit cards on your site. Thanks to some handy libraries they provide, integration is a relatively simple process.

Until recently, accepting credit cards on a website was expensive and complicated. But that was before Stripe: a radically different and insanely awesome credit card processing company. Today, I’ll show you how to start accepting cards in 30 minutes or less – without spending a dime.

They step you through the whole process you'll need to get the full flow set up:

  • Install an SSL Certificate (on your server)
  • Create an Account
  • Create Your Payment Form
  • Collect The Form Values
  • Request a Token
  • Create a Server-Side Script

Screenshots of the Stripe interface, HTML, Javascript and PHP code are all included - everything you need to make the simple card handling work. One of the keys to how Stripe deals with credit cards is that you provide it the card info, it gives you a token. Your app uses this to work with the card instead of storing the card information in your database (also making it more secure).

tagged: creditcard stripe tutorial processing javascript html php library


Server-Side HTML Handling Using phpQuery
Jun 12, 2012 @ 10:58:26

PHPMaster.com has a new tutorial today showing how you can use phpQuery to work with HTML in your application. phpQuery is a server-side CSS-selector-driven based on jQuery's API.

Think about how you can change and manipulate the generated HTML using server-side PHP code. phpQuery is the ultimate solution that will come to your mind. If you haven’t heard about phpQuery, you may be interested in this article since I am going to give you a brief introduction to phpQuery and explain how you can use it in real-world projects.

The tutorial shows you how to generate a simple table with alternating row colors (zebra) and column headers from an array of product information. They also talk a bit about why using something server-side like this is important (over something client-side like jQuery) - how it can make things easier by keeping the "business logic" all in one place, leaving your frontend to do what it does best.

tagged: tutorial phpquery backend html processing


James Cohen's Blog:
Poor Man’s Parallelization for Batch Processing Jobs
May 18, 2011 @ 11:56:31

James Cohen has a quick post about what he calls a "poor man's parallelization" for working with batch jobs. It takes in parameters that tell it which set of jobs to run through when looping.

One common problem that I’ve seen time and time again with batch processing jobs (generally cronjobs) is that when they’re written they run quickly. Over time their workload grows until eventually it’s unacceptably slow. [...] To create a simple of way of separating the jobs in a consistent way we can use the modulus operator. It just calculates the remainder of two numbers. It’s a common arithmetic operator in almost all languages so this technique is pretty portable.

His proof-of-concept script takes in two parameters, the starting job number and the number to increment. His example is user IDs, but this type of script could be used for anything with an ID number. The script is then run from the command line with the parameters of your choosing.

tagged: batch processing separation modulus


David Müller's Blog:
Parallel processing in PHP
Mar 31, 2011 @ 13:41:37

In a recent post to his blog David Müller has taken a look at parallel processing in PHP using a few different methods - system calls, fork, and curl.

Since PHP does not offer native threads, we have to get creative to do parallel processing. I will introduce 3 fundamentally different concepts to emulate multithreading as good as possible.

For each of the technologies mentioned above, he provides a simple bit of sample code that does simple tasks like echoing out strings and writing to files. He also includes some benchmarks (take them with a grain of salt) of the three different methods showing how many iterations they could run through in ten seconds. He includes the benchmarking script if you'd like to try it out yourself.

tagged: parallel processing tutorial system fork curl benchmark