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

How to Create a PHP C Extension to Manipulate Arrays Part 2: Adding ArrayAccess and
Aug 13, 2015 @ 12:33:04

Dmitry Mamontov has posted the second part of his "How to Create a PHP C Extension to Manipulate Arrays" series on PHPClasses, building on part one and adding in the ArrayAccess and Traversable interface functionality.

In the first part of this article we learned how to create an extension for PHP written in C to create a class that works like arrays. However, to make the class objects really behave as arrays you need to implement certain interfaces in the class.

Read this article to learn how to make a PHP class defined by a C extension implement ArrayAccess and Traversable interfaces, as well understand how to solve problems that you may encounter that can make your extension slower than you expect.

He takes the class he defined in part one and walks you through the addition of the two interfaces. He shows you where they're defined in the PHP source, what the code looks like and how they integrate with the class. He also shows you how to customize the object class handlers, making it possible to use the custom class (object) as an array. Adding Traversable is easier, adding an iterator return method that allows for the data internal to the class to be iterated through.

tagged: phpclasses series part2 extension class array manipulate arrayaccess traversable

Link: http://www.phpclasses.org/blog/post/306-How-to-Create-a-PHP-C-Extension-to-Manipulate-Arrays-Part-2-Adding-ArrayAccess-and-Traversable-interfaces.html

How to Create a PHP C Extension to Manipulate Arrays Part 1: Basic Array Class Exten
Aug 11, 2015 @ 10:27:24

Dmitry Mamontov has posted a the first part of a series looking at manipulating arrays in the PHP source and enhancing performance for certain handing as a PHP extension.

In PHP projects, arrays are used every where because they are useful and flexible to store all sorts of data structures. However, when you need to maximize the performance the manipulation of arrays for specific purposes, you can achieve great gains if you implement a PHP extension written in the C language. Read this tutorial to learn how to build your own basic array manipulation extension in C.

He covers all the steps you'll need to get start building the extension, introduces a few key concepts and starts on the code for the extension:

  • Building PHP from the Source
  • Building a PHP Extension (overview)
  • Brief Introduction to zval and Functions
  • Defining a Class in Our Extension
  • D for Dynamic (working with dynamic array values)

The C code needed is included through out the post. The next part in the series will build on this and show how to implement interfaces like ArrayAccess and Traversable.

tagged: extension array manipulate part1 series introduction source

Link: http://www.phpclasses.org/blog/post/304-How-to-Create-a-PHP-C-Extension-to-Manipulate-Arrays--Part-1-Basic-Array-Class-Extension.html

Smashing Magazine:
Image Manipulation With jQuery and PHP GD
Apr 05, 2011 @ 12:02:30

Smashing Magazine has a new post today about using jQuery and GD to manipulate images to upload an image, crop it and save that version to the remote server.

One of the numerous advantages brought about by the explosion of jQuery and other JavaScript libraries is the ease with which you can create interactive tools for your site. When combined with server-side technologies such as PHP, this puts a serious amount of power at your finger tips. [...] Sure, there are plugins out there that you can use to do this; but this article aims to show you what’s behind the process. You can download the source files for reference.

They walk you through the little bit of setup you'll need before things will be working and then move right into the upload form and PHP handling that goes with it. The Javascript that goes with it is all home-grown (not a plugin) and cleverly uses a DIV to simulate the bounding box for the crop.

tagged: tutorial image manipulate jquery gd crop


Creating and Manipulating PDFs with PHP and FPDF
Mar 11, 2011 @ 10:13:07

On PHPBuilder.com today there's a new tutorial about creating editing PDFs with the help of the FPDF library.

Because the Web has become the primary mechanism for distributing PDF documents, it's common to encounter questions on various web development forums pertinent to the dynamic creation of PDF documents using languages such as PHP. [...] Thankfully, such a demand for PDF manipulation capabilities exists within the PHP community that numerous alternative open source solutions have long been available, including notably FPDF.

They help you get the library installed and show you how to create a basic PDF with some simple text inside. They build on this and show how to add multiple text sections, images and watermarks.

tagged: manipulate pdf fpdf create tutorial


Image Processing with Imagine
Mar 07, 2011 @ 10:53:42

New from the php|architect blog, there's a tutorial from Mike Willbanks about using Imagine to transform images dynamically in a more object-oriented way.

Image processing in PHP is a necessary evil but is needed more often than not in just about every web application. With the various preferences in image processing libraries (think ImageMagick, GraphicsMagick and GD) it is difficult to find a library that provides a unified object oriented interface as well as implementing the general tasks in a simplistic fashion. Imagine is an open source image manipulation library built with PHP 5.3 that implements an object oriented interface to ImageMagick, GraphicsMagick and GD

Mike gives a quick sample script that uses SPL autoloading to pull in the classes as they're needed (with the "imagineLoader" method) and make a basic thumbnail from a PNG file.

tagged: imagine image process manipulate oop autoload


Padraic Brady's Blog:
Zend Framework Proposal: ZendHtmlFilter (HTML Sanitisation And Manipulation)
Sep 07, 2010 @ 10:13:17

Padraic Brady has a new post on his blog talking about a new proposal he's made for the Zend Framework about filtering and sanitizing HTML content.

For a while now, I've been keen to build a HTML Sanitisation solution for PHP. Where else would I end up putting it other than in Zend Framework? As I've explored in past articles [1] [2], HTML Sanitisation in PHP is a very inconsistent practice. [...] Isn't it possible to create a sanitiser that is both secure by default and performs well?

He talks about his Wibble tool that's become the base of his idea for a filtering feature built into the framework. It mainly uses the PHP DOM functionality and HTML Tidy for speed and parsing and was benchmarked as performing better than the HTMLPurifier tool. If you're interested, check out his proposal for its inclusion in the Zend Framework 2.0.

tagged: zendframework proposal html sanitize manipulate filter component wibble


Jeremy Cook's Blog:
Installing Imagick under Apache on Windows
Jun 08, 2010 @ 12:48:38

Jeremy Cook has put together a guide for installing Imagick on Windows so it can be used in your PHP applications..

After a few weeks of experimenting on and off I've just managed to get the Imagick extension installed under Apache on Windows (my development environment). While discovering how to make it work was not at all simple the final process of getting all the pieces to play together nicely was pretty easy. In this post I'll briefly discuss what ImageMagick and the Imagick extension for PHP are, why you might want to use them, how I got them up and running and finally a very simple piece of example code. I'm hoping this post will help people avoid the frustration and effort I went through to get them to work!

He explains what the tools (ImageMagick & Imagick) are and why it's a bit more difficult to install them on Windows than just a point and click sort of thing. He walks you through an eight-step process that will have you up and working in no time and includes a simple PHP script you can run to ensure things are working as they should.

tagged: windows imagick install tutorial image manipulate


CodeIgniter from Scratch: File Uploading and Image Manipulation
Feb 23, 2010 @ 08:09:17

On NETTUTS.com there's a recent tutorial - the ninth part of the "CodeIgniter from Scratch" series - posted (by Burak Guzel) for all of the users of this popular framework out there. It looks at, starting from the very beginning, how to create an upload and image manipulation script for use in the framework.

In lesson nine of our CodeIgniter series, we'll build a small image gallery that allows you to upload files, and automatically create thumbnails

He links to the previous eight parts of the series if you need to catch up as well as the source code for this installment so you can follow along with the screencast. For those more on the go, you can also download the screencast and watch it whenever.

tagged: tutorial file upload image manipulate screencast


Zend Developer Zone:
Manipulating Images with PHP and GraphicsMagick
Sep 29, 2009 @ 11:56:38

The Zend Developer Zone has a new tutorial from Vikram Vaswani on working with GraphicsMagik to create and manipulate images in your PHP scripts.

Based on the robust, multi-threaded GraphicsMagick library, aka the "Swiss Army knife of image processing", PHP's GraphicsMagick extension allows developers to add street cred to their image (sorry, I couldn't resist!) with some fairly powerful API methods. This article discusses the extension in detail, introducing you to its key functions and showing you how to rotate, resample, transform, crop, carve, and otherwise mangle your images until they roll over and beg for mercy.

The tutorial looks at how to get the package installed (both from source or as a pecl package) and how to check and make sure it's up and working. The sample scripts included show you how to grab the info about an image, resize it, write it out to a file, rotate/flip it and do a few other fun tricks (including using built-in filters).

tagged: graphicsmagik tutorial image manipulate


Vito Chin's Blog:
The Gmagick Extension
May 18, 2009 @ 11:51:22

Vito Chin has announced the release of a new image manipulation extension that was ported from Imagick - Gmagick.

The extension seeks to make the image processing capability of GraphicsMagick accessible from PHP. GraphicsMagick is forked from version 5.5.2 of ImageMagick and had since developed with important differences and improvements. [...] In terms of Gmagick and Imagick, we try to keep the method interface similar so existing Imagick users will find converting to Gmagick a breeze.

You can grab the extension from its PECL page.

tagged: imagick manipulate image extension gmagick