15 best PHP Libraries for Developers

PHP is widely used server side scripting language. Every day lots of useful libraries released with help of composer and github they are easy to find and use. PHP Library allows developers to take full advantage of Object Oriented Programming in PHP. In this article we collect a list of 15 best PHP Libraries for Developers. That will help to developers to do number of things easily with less efforts.

1. ImageWorkshop — Image Manipulation with Layers

PHP Image Workshop is an open source class using GD library that helps you to manage images with PHP.with this you can create thumbnails or pasting watermarks and also to do more complex tasks multiple superimpositions, image positioning.


// We initialize the norway layer from the picture norway.jpg


// We initialize the watermark layer from the picture watermark.png


// This is the generated image !


header(‘Content-type: image/jpeg’);

imagejpeg($image,null,95);// We choose to show a JPG with a quality of 95%


2. PHP Error — error messages,Syntax highlighting

PHP Error is an open source PHP library for converting the standard PHP error messages -that are usually faced during the development process- into better ones.It integrates tightly into any PHP environment (works on all cases, only in development environment, only in some projects, etc.) and displays the errors with syntax highlighting.



// place at start of site



// wordpress

// open the ‘functions.php’ file in your WordPress theme



// codeigniter

// place php_error.php in your application folder.






3. Validation — Input Validation Engine

The most awesome validation engine ever created for PHP is Validation


useRespect\Validation\Validator asv;

// Simple Validation



// Chained Validation



// Validating Object Attributes




// Validate its attributes in a single chain:




4. phpfastcache : The PHP high-performance object caching system ever.

phpFastCache is a high-performance, distributed object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.



// In your config file


// phpFastCache::setup(“storage”,”redis”); default global for everywhere.

// phpFastCache support “redis”, “cookie”, “apc”, “memcache”, “memcached”, “wincache” ,”files”, “sqlite” and “xcache”

// You don’t need to change your code when you change your caching system, blank will use default global:


// $cache = phpFastCache(“memcache”);

// In your Class, Functions, PHP Pages

// try to get from Cache first. product_page = YOUR Identity Keyword




// set products in to cache in 600 seconds = 10 minutes and 0 = never expired


// Output Your Contents $products HERE

// LOOP | echo $products

5. Omnipay- Payment Processing Library

Omnipay is a payment processing library for PHP. It has been designed based on ideas from Active Merchant, plus experience implementing dozens of gateways for CI Merchant.









// payment was successful: update database



// redirect to offsite payment gateway



// payment failed: display message to customer


6. Upload — For Handling File Uploads

Upload is a library that simplifies file uploading and validation. When a form is submitted, the library can check the type of file and size:




// Validate file upload


// Ensure file is of type “image/png”


// Ensure file is no larger than 5M (use “B”, “K”, M”, or “G”)



// Try to upload file


// Success!



// Fail!


7. PHP CPP Library — for developing PHP extensions.

The PHP-CPP library is a C++ library for developing PHP extensions. It offers a collection of well documented and easy-to-use classes that can be used and extended to build native extensions for PHP.


//Native c++ function

Php::Value hello_world()

return”hello world!”;

// With PHP-CPP you can export this function to PHP with only one single C++ method call:


//Working with parameters and return values is just as easy:

Php::Value my_plus(Php::Parameters&params)


//The method call to export the above C++ function:





8. Mustache.php -simple, logic-less template engine

Mustache.php “logic-less” because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some with nothing, and others with a series of values. The Benefit of Mustache.php is that you can reuse your templates in both client and server side


echo$m->render(‘Hello {{planet}}’,array(‘planet’=>’World!’));// “Hello World!”

9.Geocoder-powerful abstraction layer for geocoding manipulations

Geocoder is a PHP library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations.

























10. PHP-PasswordLib- library for generating and validating passwords

PHP-PasswordLib aims to be an all-inclusive cryptographic library for all cryptographic needs. It is meant to be easy to install and use, yet extensible and powerful enough for even the most experienced developer.





11. HTMLPurifier — XSS Protection

HTML Purifieris a standards-compliant HTML filter library written in PHP.HTML Purifier protects your code from XSS attacks by using a combination of robust whitelists and agressive parsing







12.Faker — generates fake data

Faker is a PHP library that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress this will generate fake data.


// require the Faker autoloader


// use the factory to create a Faker\Generator instance


// generate data by accessing properties

echo$faker->name;// ‘Lucy Cechtelar’;


// “426 Jordy Lodge

// Cartwrightshire, SC 88120–6700"


// Sint velit eveniet. Rerum atque repellat voluptatem quia …

13.Snappy- For thumbnail, snapshot or PDF generation from a url or a html page

Snappy is a PHP5 library allowing thumbnail, snapshot or PDF generation from a url or a html page.





// or you can do it in two steps



// Display the resulting pdf in the browser

// by setting the Content-type header to pdf


header(‘Content-Type: application/pdf’);

header(‘Content-Disposition: attachment; filename=”file.pdf”’);


// Merge multiple urls into one pdf

// by sending an array of urls to getOutput()


header(‘Content-Type: application/pdf’);

header(‘Content-Disposition: attachment; filename=”file.pdf”’);


// .. or simply save the PDF to a file


$snappy->generateFromHtml(‘<h1>Bill</h1><p>You owe me money, dude.</p>’,’/tmp/bill-123.pdf’);

// Pass options to snappy

// Type wkhtmltopdf -H to see the list of options







// .. or pass a cover as html

$snappy->setOption(‘cover’,’<h1>Bill cover</h1>’);


14. Colorjizz-manipulating and converting colors

Colorjizz is a tiny library that can convert between different color formats and do simple color arithmetic

//ColorJizz can convert to and from any of the supported color formats:





echoget_class($red_cmyk);// MischiefCollective\ColorJizz\Formats\CMYK

echo$red_cmyk;// 0,1,1,0

Opauth — multi-provider authentication framework for PHP

Opauth is an open source PHP library that removes the inconsistencies between providers and offers a standardized method for dealing with them. Currently, 3 providers are almost plug ‘n’ play: Google, Twitter + Facebook and there are more to come. Also, there is support for dealing with any other Opauth provider.

I hope you find the list handy and useful for your development tasks, if you are aware of any other useful php libraries, then please provide us your feedback by dropping a comment below. Enjoy !!

Originally published at phplesson.com on May 7, 2015.

Like what you read? Give Rohit Gilbile a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.