Dynamic Generation of PDFs with FPDF/FPDI

July 6th, 2007


In a recent project I needed to build quite a few dynamic pdfs, with information filled from a database. This led me to two great pieces of PHP code, FPDF and FPDI. FPDF allows for building new pdf documents from scratch, while FPDI allows for manipulation of already existing pdf documents. FPDI is an extension of FPDF, so utilizing both is a minor triviality.

FPDF:
FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. FPDF requires no extension (except zlib to activate compression) and works with PHP4 and PHP5.

FPDI:
FPDI extracts and imports single pages of existing documents into FPDF. The resulting PDF created by FPDF/FPDI is a completely new document. Please don't misunderstand: with FPDI you cannot edit a PDF.
Utilizing FPDF/I I was able to build a 32 page dynamic pdf set over a couple of days. Needless to say, both FPDF and FPDI are very handy tools, and have an amazing amount of potential.

PHP Data Sources with Flex/ActionScript

March 7th, 2007


For Adobe Flex and ActionScript coders, communication with PHP data sources can be an absolute pain. There are no direct methods for communication, which usually leads to developing two completely different systems: a PHP system which writes data to an external file (XML, HTML, or text) and another Flex/AS3 system for interacting with the external file.

Luckily for these developers however, there is a toolkit designed to ease the burden of PHP data sources within Flex/AS3. AMFPHP, originally designed by Wolfgang Hamann, is an RPC toolkit PHP, allowing seamless communication between PHP and Flash/Flex/ActionScript, Javascript and AJAX, and XML with XML-RPC. More information directly from the site:

RPC (Remote Procedure Call) is a way to communicate data between a client and a server. You call a method on a local object with various parameters, set a callback, and receive a result. You don’t have to worry about how you’re going to send and receive the data. The server and the client, say php and Flash, agree on a common way of describing method calls and complex data. The implementation details are abstracted away so that it looks as though you’re calling a local method.

Amfphp lets you focus on features instead of implementation details. Testing remote services can be tricky, so amfphp has a built-in service browser which lets you test your services before you start writing the front end, and allows you to generate code for various clients. You can check it out here.

AMFPHP was designed with a few simple goals in mind:
  • Nothing required - PHP4/PHP5 compatible, no extensions needed
  • Low footprint, lightweight, fast
  • Convention over configuration (service and class mapping)
  • Can be embedded into a framework (see CakeAmfphp, Seagull)
  • Services are “non-specific” PHP classes that are portable to anything without code change
  • Productivity tools included (service browser, code gen, profiling)
  • Batteries included - XML-RPC, JSON
  • Not a framework by itself (use your own)
I live by AMFPHP when developing with Flex and Actionscript. Another priceless development tool which you will come to treasure if you give it a chance. As always, you can find more information as well as download information from the AMFPHP Homepage

Tags: , , , , ,

Debugging PHP in Dreamweaver

February 18th, 2007


Dreamweaver is a great PHP development tool, and today I found an extension that makes it an even more productive development tool. IPT Solutions’ PHP Debugger extension allows developers the ability to debug their PHP directly from within the Dreamweaver environment. Straight from the site, here’s a list of what you can expect with this extension:
  • Simple and intuitive user interface.
  • Option to choose which error types you want to be reported by PHP Debugger.
  • Preview of the source, exactly where the error appears.
  • You can view 12 line above and 12 below the error line to easy locate the problem.
  • By clicking on the error line you will be located directly to the file and line of the problem.
  • Start debugging with already assigned shortcut: Ctrl+Alt+Z.
So, head on over to the PHP Debugger download page and give it a try.

Tags: , , , ,

PHP in Visual Studio

February 15th, 2007


Visual Studio is Microsoft’s flagship .net development environment and is considered by most to be the tool of choice for .Net development, but like all of Microsoft’s development products, it only supports languages encompassed by .Net. Wouldn’t it be nice to be able to use Visual Studio for PHP as well as .Net? The team at Jcx.Software thought so, creating a fantastic Visual Studio add-on for PHP development known as VS.PHP.

Here is a brief overview of what VS.PHP brings to Visual Studio:
  • PHP Syntax Highlighting
  • Smarty Template support
  • Code snippets
  • Code auto formatting

This is not a complete feature list by any means. I suggest heading over to the VS.PHP Product Page to see for yourself all the features this software brings to VS. I highly recommend this software for any PHP developer.

Unfortunately VS.PHP is not freeware, however for professional developers, the $99 price tag is a small price to pay for what you get in return.

Tags: , , , , ,