Today millions of websites and servers across the Internet are powered by PHP. Originally created by Rasmus Lerdorf in 1995 so that anyone can easily create a Personal Home Page; PHP has come a long way and is now widely used as general purpose scripting language that is suitable for majority of web development projects.
Numerous PHP Frameworks have evolved to enable rapid web development with PHP. However even greater number of standalone PHP libraries and classes are available which provide similar benefits. W3Avenue has compiled a list of some really useful classes and libraries that every PHP developers should be familiar with. Whether you like to use a PHP Framework or prefer to work without one, your productivity can multiply with the help of these libraries and classes.
- ADOdbAn object oriented library written in PHP that abstracts database operations for portability. It is modeled on Microsoft’s ADO, but has many improvements that make it unique (eg. Pivot Tables, Active Record support, generating HTML for paging recordsets with next and previous links, cached recordsets, HTML menu generation, etc). Supports large number of databases including: MySQL, PostgreSQL, Interbase, Firebird, Informix, Oracle, MS SQL, Foxpro, Access, ADO, Sybase, FrontBase, DB2, SAP DB, SQLite, Netezza, LDAP, and generic ODBC, ODBTP.
- RedBeanRedBean is an easy, lightweight ORM for PHP that doesn’t require any configuration and works out of the box. The only requirement is a database connection string; it offer a single setup-class that gets you up and running with just 1 single method invocation.
- DoctrineDoctrine is an object relational mapper (ORM) for PHP 5.2.3+ that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.
- PHPLINQA set of PHP classes mimicing C#3.0’s LINQ (Language Integrated Query) extension methods.PHPLinq currently features: LINQ operators (select, take, skip, orderBy / orderByDescending, thenBy / thenByDescending), Lambda expressions, and Anonymous types.
- MimesisMimesis is an Open Source PHP Flat File Database low-level API designed to act as a backend for server-side scripts that require database functionality. Instead of parsing SQL statements, Mimesis uses PHP’s object-oriented constructs to provide a distinct class with various database manipulation methods.
- PHP CodeSnifferPHP CodeSniffer is a PHP5 script that tokenizes and “sniffs” PHP code to detect violations of a defined set of coding standards. It is an essential development tool that ensures that your code remains clean and consistent. It can even help prevent some common semantic errors made by developers.
- phpDocumentorSimilar to Javadoc, and written in php, phpDocumentor can be used from the command line or a web interface to create professional documentation from php source code. phpDocumentor has support for linking between documentation, incorporating user level documents like tutorials and creation of highlighted source code with cross referencing to PHP general documentation.
- TCPDFAn Open Source PHP class for generating PDF documents. Requires no external libraries for the basic functions; supports all ISO page formats including UTF-8, Unicode, RTL languages and HTML.
- PHPPowerPointBased on Microsoft’s OpenXML standard PHPPowerPoint Classes enables you to read and write PowerPoint files. Features include: setting presentation meta data (author, title, description, …), adding slides, adding images to your presentation and much more!
- PHPExcelBased on Microsoft’s OpenXML standard PHPExcel Class enables you to read and write Excel files. Features include: setting spreadsheet meta data (author, title, description, …), multiple worksheets, different fonts and font styles, cell borders, fills, gradients, adding images to your spreadsheet and much, much more!
- PhpRtf LitePurpose of this library is to create RTF documents with PHP, which are compatible with Microsoft Word and Open Office Writer programs. Main features include: Document sections formatting: margins, paper size, borders and other (document can have more than one section); Headers and footer formatting; Paragraph control: background, borders, alignment and other; Font control: bold, italic, face, size, color (it’s possible to use html style tags); Embedded images (.jpg and .png formats); Tables formatting: sizes, borders, background and alignment of cells; UTF-8 support.
- PclZipOffers compression and extraction functions for Zip formatted archives (WinZip, PKZIP). It gives you the ability to create an archive, list the content and extract all its content in the file system. PclZip defines an object class which represent a Zip Archive. This class manages the archive properties and offers access method and actions on the archive.
- Swift MailerSwift Mailer integrates into any web app written in PHP 5, offering a flexible and elegant object-oriented approach to sending emails with a multitude of features: Send emails using SMTP, Sendmail, Postfix or a custom Transport implementation of your own, Support servers that require username & password and/or encryption, Protect from header injection attacks without stripping request data content, Send MIME compliant HTML/multipart emails, Use event-driven plugins to customize the library, Handle large attachments and inline/embedded images with low memory use.
- PHPMailerFull featured email transfer class for PHP. PHPMailer features: Supports emails digitally signed with S/MIME encryption, Supports emails with multiple TOs, CCs, BCCs and REPLY-TOs, Supports Text & HTML emails, Embedded image support, Multipart/alternative emails for mail clients that do not read HTML email, Redundant SMTP servers, SMTP authentication, Tested on multiple SMTP servers: Sendmail, qmail, Postfix, Gmail, Imail, Exchange, etc.
- SecurimageAn open-source free PHP CAPTCHA script for generating complex images and CAPTCHA codes to protect forms from spam and abuse. It can be easily added into existing forms on your website to provide protection from spam bots.
HTML / CSS
- HTML PurifierHTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive white list, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C’s specifications.
- GeSHi – Generic Syntax HighlighterGeSHi is a syntax highlighter for HTML, written in PHP. Basically, you input the source you want to highlight and the name of the language you want to highlight it in, and GeSHi returns the syntax-highlighted result. But it doesn’t stop there – GeSHi has many powerful and unique features, including: The ability to change the styles of any highlighted element on the fly, Use of CSS classes to reduce the amount of output produced (GeSHi can also produce a stylesheet to be used with a language on the fly), XHTML 1.0 Strict + CSS2 compliance, Auto-caps/noncaps of keywords, Line numbering (both normal and fancy forms, see the demo, and many more!
Image / Media / File
- AsidoA PHP image processing solution, with “pluggable” drivers(adapters) for virtually any environment: GD2, Magick Wand, Image Magick via shell, Image Magick via extension, etc. Asido offers the following functionality: resize images, watermark images, rotate imates, copy images, crop images, grayscale images, convert images.
- PHP ThumbA light-weight image manipulation library aimed at thumbnail generation. It features the ability to resize by width, height, and percentage, create custom crops, or square crops from the center, and rotate the image. You can also easily add custom functionality to the library through plugins. It also features the ability to perform multiple manipulations per instance (also known as chaining), without the need to save and re-initialize the class with every manipulation.
- WideImageWideImage is an object-oriented library for image manipulation. The library focuses on often-used image operations and ease of use. It provides a simple and unified way to loading and saving images from/to files, strings, database and even URLs (load only, must be enabled in PHP). Supports the most common image formats: GIF, PNG, JPEG, GD and GD2.
- Smart Image ResizerAllows you to resize and crop any image on your website without touching the actual image or writing any code. Simply upload each image once at a high enough resolution and then reuse it at any size you want, anywhere you want. Features include: Resizes JPEGs, GIFs, and PNGs, Intelligently sharpens for crisp photos at any size, Can crop based on width:height ratios, Can color-fill transparent GIFs and PNGs, Built-in caching keeps image variations for optimal performance.
- class.upload.phpThis PHP script uploads files and manipulates images very easily. The perfect script to generate thumbnails or create a photo gallery! It can convert, resize and work on uploaded images in many ways, add labels, watermarks and reflections and other image editing features. You can use it for files uploaded through an HTML form, a Flash uploader, or on local files.
- getID3()A PHP script that extracts useful information (such as ID3 tags, bitrate, playtime, etc.) from MP3s & other multimedia file formats (Ogg, WMA, WMV, ASF, WAV, AVI, AAC, VQF, FLAC, MusePack, Real, QuickTime, Monkey’s Audio, MIDI and more).
- PHP PSD ReaderPHP comes with built-in support to read and write images in many formats using the GD library. However, it does not support the Photoshop image format: PSD. This class fill partly that void by reading Photoshop PSD image files and creating a GD image resource from the Photoshop image bitmaps.
- Xmf ParserExtensible Microformats Parser for PHP 5. Currently supported Microformats include: xfn, rel-license, rel-tag, geo, adr, hcard, hcalendar, hreview, hresume.
- iCalcreatoriCalcreator is a PHP class managing iCal formatted files for non-calendar systems like CMS, project management systems and other applications able to process calendar information. iCalcreator features create, parse, edit and select calendar and calendar components.
- hKitA simple PHP5 tool for extracting common microformats from a page. The page can be presented as a string or a URL, and the result is handed back as a standard PHP array structure. hkit uses SimpleXML for parsing, and therefore requires PHP5.
- TransformrA Simple set of XSLT and PHP tools for Transforming Microformats.
RSS & Atom Feeds
- SimplePieAn open sources PHP class that provides an easy to use API for handling all of the dirty work when it comes to fetching, caching, parsing, normalizing data structures between RSS and Atom formats, handling character encoding translation, and sanitizing the resulting data.
- PHP Intrusion Detection System (PHPIDS)A simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application. The IDS neither strips, sanitizes nor filters any malicious input, it simply recognizes when an attacker tries to break your site and reacts in exactly the way you want it to. Currently the PHPIDS detects all sorts of XSS, SQL Injection, header injection, directory traversal, RFE/LFI, DoS and LDAP attacks. Based on a set of approved and heavily tested filter rules any attack is given a numerical impact rating which makes it easy to decide what kind of action should follow the hacking attempt. This could range from simple logging to sending out an emergency mail to the development team, displaying a warning message for the attacker or even ending the user’s session.
Testing & Debugging
- PHPUnitPHPUnit is a member of the xUnit family of testing frameworks and provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyze their results.
- SimpleTestSimpleTest is is similar to JUnit/PHPUnit. It supports mock objects and can be used to automate the regression testing of web applications with a scriptable HTTP Client that can parse HTML pages and simulate things like clicking on links and submitting forms.
- PHP DebugProvides assistance in debugging PHP code, by program trace, variables display, process time, included files, queries executed, watch variables… This information is gathered through the script execution and therefore are displayed at the end of the script (in a nice floating div or a html table) so that it can be read and used at any moment.
- XML-RPC Library for PHPa fully compliant XML-RPC client and server written in pure PHP. Only requirements are PHP, and the XML parser you’re guaranteed to have if you’re using PHP built into Apache (which most people are).
- PHP API Libraries & Wrapper Classes For Popular Services
- Find More Web Services API at ProgrammableWeb
- WPGetWPGet is a script that is designed to allow you to include a short summary of your recent blog posts on your website. Specifically, it works with WordPress and is great for integrating a WordPress blog into a site that isn’t completely powered by the WP platform.
Here are some additional resources to help you find PHP classes, libraries and code snippets that you may still be looking for:
- PHP Classes
- The PHP Resource Index
- Best PHP Scripts
- Codango PHP Resource Guide
- 15 very useful PHP code snippets for PHP developers – ViralPatel
- 21 Really Useful & Handy PHP Code Snippets – Web Developer Plus
- Jonas John’s PHP Snippets Collection
Please feel free to suggest any addition, correction or updates in your comments. You may also want to look at:
- Really Useful Tools For PHP Developers
- List of Really Useful Plugins For jQuery Developers
- List of Really Useful Tools for CSS Developers
- List of Really Useful Plugins and Resources For MooTools