PHP is an amazing and powerful web development language. It is being used by more than 80% of the total web applications available globally. PHP is very easy to learn and implement, and also there are many PHP library out there that can do a lot of work for you.

From basic OAuth authentication to complex web sockets that you can use in a chat application. They are actually trusted by big companies as well as used by many developers but before using them make sure you have composer installed!

  1. Ratchet

    It is a PHP library that is used for web sockets. Basically, web sockets are used in real-time applications like a chat application or push notifications. Ratchet is basically an event-driven library rather than basic HTTP request. It is used for bi-directional communication between client and server. Ratchet is a bit different from web sockets since, in normal web sockets with each page load on client’s side, it’ll load on server side as well, launch a new PHP script, loads all other resources like database connection, execute the code, closes all the resources and sends the output and closes the connection. This is a foolproof HTTP protocol that is being used since a very long period of time. On the other hand in ratchet, only one script is executed and the connections are kept open and data is transferred in both direction.

    Composer command: php ~/composer.phar require cboden/ratchet

  2. OAuth

    It is a widely accepted authentication method. OAuth is being used by big companies like Google, Facebook, Microsoft, Amazon etc. This PHP library is used for authentication without sharing passwords. OAuth basically uses an access token and is designed specially to work with HTTP requests. OAuth is mostly used in API authentication where the client needs to share the access token and if it is valid, the client can access the data and also needs to share the token with each request. OAuth is not specific to PHP, but to other languages as well and can be implemented on server-side only.

    Composer command: composer require bshaffer/oauth2-server-php "^1.10"

  3. Botman

    A PHP library that you can use to build chatbots. So chatbots are booming now days specially on the platform like Facebook, Telegram, Slack, Nexmo, WeChat, Nexmo, Microsoft Bot Framework etc. Botman is a PHP library that you can use to make your own bot for the above-mentioned platform. Now you don’t need to read docs for each and every platform, connect API and create chatbots. This is all on one library for all the bots. The best part of botman is that It is open source and apart from core PHP it can be easily integrated with CodeIgniter or Laravel. You have two options either create your own drive that you can use to connect Botman library with other platforms or make an API connection with botman. The choice completely depends on your requirements. And for all data science enthusiasts it also supports NLP.

    Composer Command: composer global require "botman/installer"

  1. Math PHP

    As the name suggests, it is a collection of mathematical functions ranging from simple calculation to complex numerical analysis. Math PHP library is completely independent and works straightaway. Its features includes Algebra, Arithmetic, Finance, Functions like Map and Polynomial, Information theory (Entropy), Linear Algebra (Matrix, Vector), Numbers (Arbitrary Integer, Complex, Rational), Number Theory (Integers), Numerical Analysis (Interpolation, Numerical Differentiation, Numerical Integration, Root Finding), Probability (Combinatorics, Distributions), Sequences (Basic, Advanced, Non-Integer), Set Theory, Statistics (Anova, Averages, Circulation, Correlation, Descriptive, Distance, Divergence, Distributions, Effect Size, Experiments, Kernel Density Estimation, Multivariance, Outlier, Random Variable, Regressions, Signification testing), Trigonometry. Phew!! So many features!! So if you’re looking for all in one library for math function, well, this is the one.

    Composer Command: php composer.phar require markrogoyski/math-php:0.*

  2. Dispatch:

    This PHP library is basically used to handle HTTP requests. Dispatch library can be used to create API as they’re mostly dependent on routes. It doesn’t exactly provide you with the functionality of MVC but can help you to define URL rules and methods to organize your web applications. Dispatch library uses action and server for handling requests. The action function defined the method, route, and handles all the model part where all the database query is executed. While serve uses the route, request method, path and config to send the response.

  3. Klein

    This is another library to define routes. Klein is one of the fasted routers for PHP. It can handle up to 2500 requests per second, and also allows regular expression routing. Klein works amazingly fast for small applications, but you have to keep in mind that your code can become unmanageable if you’re building a complex or a big project.

    Composer Command: php composer.phar require klein/klein

  4. Faker

    It is a PHP library that generates fake data for your database, or you want to test the database with some dummy data. Faker is based on Perl’s Data:: Faker and Ruby’s Faker. So how does it work? Faker has Faker Factory that you can use to create and initialize a faker generator. On the generator side, you can access the generator properties like formatters, which actually generates the dummy data. By default Faker uses English locale, it also supports other locales as well. Faker can fake data like names, locale data, titles, colours, numbers, unique numbers, internet related data, XML data, phone numbers, address, user agent, barcode, company, date and time, Uid etc. By locale data I mean, if you’ll ask faker to generate name, city, phone number then it’ll generate the localized data depending on locale used. For example, if I set the locale to Slovak then it’ll generate Agáta Molnárová, Čabalovce, +421 857 627 309 and so on.

    Composer Command: composer require fzaninotto/faker

  5. Carbon

    This PHP library is used for date and time. But date-time is already there in PHP, right? Well, Carbon is not just about date and time. You can easily check for conditions like a weekday, weekend, yesterday, is past, is the same day, is birthday etc. The feature list also includes the start of x or end of x for example start of the day, end of the day, end of the decade, the start of the week, end of the century, end of the week etc. It also supports different locales like de, en, etc. Addition and subtraction also become very easy. The library is so powerful that Laravel has already included this in their library. It also allows you to convert time to different time zones without changing the default time zone.

    Composer Command:composer require nesbot/carbon

  6. OpAuth

    It is another library for authentication that removes the inconsistent methods and provides a standard way of authentication. Opauth comes preloaded with Google, Twitter and Facebook authentication. This PHP library is inspired by Omni AUTH for ruby. It provides the developer with a set of API that can work across different PHP frameworks. Opauth supports most the PHP frameworks like CakePHP, CodeIgniter, FuelPHP, Laravel, PrestaShop, Silex, YiiFramework, Zend, Nette, and of course Core PHP. There are different strategies available on their website and yes you can create your own as well, some of the strategies are listed by Bitbucket, Facebook, Google, Flickr, Instagram etc. Installing OpAuth, add the below code to your composer.json:

             "opauth/opauth": "*",
             "opauth/facebook": "*",
             "opauth/google": "*",
             "opauth/twitter": "*"

    Run command: php composer.phar install

  1. PHP fast cache

    Your website has 10,000 users right now who are online at the same time. Now your PHP website has to send 10,000+ request to the database even it’ll execute the same query. Don’t you think that’s too much workload? That’s where PHP fast cache comes into play. It is a backend caching library intended for speeding up PHP web applications. It drops the database load which helps in faster PHP execution which then results in faster page load.

    Composer Command: composer require phpfastcache/phpfastcache

  1. PHP Captcha

    Now we have made your website faster using PHP fast cache. Now some bad guys start to exploit your website by sending too many bots. This is where PHP captcha comes into play. PHP Captcha is a PHP library that creates generates audio and visual captchas. They’re like a mini quiz that a user has to solve before login/signing in. So, a bot can never work on a website that has this type of security.Download link:

  2. PHPMailer

    This is probably the most popular PHP library for SMTP, or you can say sending emails. PHP mailer is used by big open sources projects like WordPress, Drupal, Yii, Joomla and many more. It makes the SMTP so easy that you just have to pass the email name server and your login and it starts working. PHP mailer also supports content like UTF-8, 8bit and much more. PHPmailer has got more than 14k start on git hub which is a big deal. If you don’t like PHPmailer you have another alternative also which is swiftmailer.

    Composer command: composer require phpmailer/phpmailer


    It is a class implementation for PHP code that can support encryption method cypher of 182, 192- and 256-bit AES or Advanced Encryption Standard. The PHPAES library is not dependent on any other extension for compilation rather it uses 100% PHP only. Many times you would not want to store user credentials directly into the database, PHPAES can be used to encrypt the user credentials and store it directly into the database. To cypher and decipher the credentials you would need to generate a key, which you can encrypt to make it much safer.

    Composer command: composer require phpaes/phpaes

  2. PHP text to image

    This is an interesting PHP library. PHP text to image library converts text into an image. For example, you enter an email then this PHP library will generate an image for that email. The benefit for using this library specially in terms of email storing is that it’ll display the email but won’t allow the web scrappers to scrape the emails and make it as junk emails. In this PHP library, you can define the custom dimension, text colours, font size width etc.

    Composer command: composer require rathouz/text-image

  1. PHP export data

    A fast and amazing library to export data into XML, CSV or TSV data. PHP export data allows you to display the data on a browser, download to a file or store in a file, completely depends on your choice. So this library has many other benefits as well, suppose you get an array of data (large volume data) and now you want to store it into the database. Will you be using INSERT statements in a loop? That’s completely insane!! You can use this library and get the data array stores in a CSV, TSV or XML format and use LOCAL INFILE query to upload the data in bulk. It’s that simple. So instead of millions of INSERT statement, you’re now using one statement to insert millions of rows.

    Download link:

  1. PHP Spreadsheet

    The PHP export data library which we discussed above is based on this library. PHP. The spreadsheet uses an array of data and dumps into a Microsoft Excel sheet or Open Office readable format. It is an official successor of PHP Excel which was one of the best PHP libraries for dumping data in Microsoft Excel.PHP spreadsheet supports not only XLSX but also .XLS, .ODS, .XML and PDF. The PHP excel became obsolete because it couldn’t support PHP 7.1 and since PHP spreadsheet is the successor of PHP Excel, its basic requirement is PHP 7.1.

    Composer command: composer require phpoffice/phpspreadsheet

  1. Geocoder PHP

    This PHP library is used to create Geo location-based web applications by using an abstract layer of geocoding manipulations. Geocoder library is divided into three parts, the first one is HTTP Adapter layer which is used to make requests. The second part is the Geocoding providers which are basically Geocoder functions and classes. And the third one is Formatter/Dumpers which are used to format the output. The input for Geocoder can be anything like your neighbourhood, street, city, country, or state. Though it provides a lot of input options its output is heavily dependent on the given input. Hence the more accurate the input is the better output you get.

    Composer command: composer require geocoder-php/google-maps-provider php-http/guzzle6-adapter

  1. PHP Password Library

    This library is based on Python’s Passlib. PHP password Library is used to hash passwords using schemes like BCrypt, BSDi, Extended DES, DES Crypt, SHA-1, SHA-256, or SHA-512. It is an amazing PHP library for generating password hashes. The library also allows you to calculate the strength of a password, so if you want the user who is registering on your website to use a secured password you can indicate him by this. Installation via composer, create a composer.json with below lines:

           "rych/phpass": "3.0.*@beta",

Run command: php composer.phar install

  1. PHPSecLib

    This library is used to make SFTP connections. PHP Sec Lib stands for PHP Secure Library, used to make the secured connection for communication. The library is very compatible and requires PHP 4+ also is not dependent on any other extension.

    Composer command: composer require phpseclib/phpseclib:~1.0

  2. PHP Debug

    This PHP library is completely open-source and can give a lot of useful information about PHP code for debugging. It can output results like execution time of your PHP script, also check the performance of a particular block of code and show all the results in a graphical form.Download link:

  1. Selenium

    It is a set of libraries which helps to automate browser-based actions. Suppose you have created a register page and you want to create multiple users for testing, one way is that you manually go to that page fill form manually. Another way is that you create a test module using Selenium and it’ll automatically insert all the fields on behalf of you. Sounds simple right? You just need to install selenium web drive and code it. It uses JDK also with Chromium. It uses identifiers on a web page like id, XPath, classes, tags, or any other attribute.

    Composer command: php composer.phar require php-webdriver/webdriver

  2. Cronos

    This library is used to set and update crons using PHP. You need to have access and rights to edit the crontab file in order to set and update crons. This library is very useful as to setup crons without this library is a task in itself. Like you need to login to the server and then many rounds of terminal commands. But with Cronos, you can even create your own UI to update and set crons.Create a composer.json file and paste the below code:

         "require": {
             "mybuilder/cronos": "~1.0"

    Now run the command: composer install

  1. Socialworth

    This is a PHP library which can determine the popularity of a URL using social network APIs. Right now it supports social network like Twitter, Facebook, Google+, Pinterest, Reddit, StumbleUpon and LinkedIn. Socialworth’s features include the number of shares, most popular link on a specific social network, post share count etc. So you can reduce the number of external JavaScript includes which basically shows the number of shares and use this library. This will not only reduce the website load time but also reduce the number of JS calls.Add below code to composer.json:

         "require": {
             "evansims/socialworth": "*"

    Run command: composer install

  1. PHP CPP Library

    A C++ library for developing PHP extensions. It is very easy to use and simple to understand. So basically to native PHP extensions are loaded into file systems like .dll or .so in Windows and Unix based operating systems respectively and they are loaded by the php.ini file by default. So now if you want to create your own extension you would have to create the same .dll or .so file. This is where PHP CPP comes into play, it not only helps you to skip the above-mentioned hassle but also lets you load them without worry.Download link:

  1. Swiftmailer

    This PHP library is an alternative for PHPmailer library. Swiftmailer is clean and simple to use. This library includes all the feature of the PHPmailer library to send emails. PHPmailer works perfectly but is not being maintained enough and also Swiftmailer has a better and bigger user base.

    Composer command: composer require "swiftmailer/swiftmailer:^6.0"

  1. Requests

    This is another HTTP request library for PHP. This library was inspired by Requests Python Library. This library is licensed under ISC license and has is not dependent on any other library except for PHP version, which is PHP 5.4+ is minimum required. The Requests library allows you to send all type of HTTP request that is HEAD, GET, POST, PUT, PATCH and DELETE. By default, it has a special function for Basic Auth and you can also define your own authentication. It also allows you to read status codes specifically for any request type.Create a composer.json and paste the below code:

         "require": {
             "rmccue/requests": ">=1.0"

    Run command: composer install

  1. Underscore

    This library is based on the underscore library which is available for Node JS. It includes all the functionality of underscore.js and also allows you to perform unit tests. Underscore PHP is completely opensource which means you can make any change you want according to your needs. So, what is Underscore library for? This library allows you to perform more than 100 operations on your array! For example, you can traverse an array, union, intersection, and what not! You should definitely go and check out this PHP library.Download link:

  1. Munee

    This PHP library will help you to optimize your assets like CSS, JS, Image compression and CoffeeScript. Munee is dependent on Imagine, an OOP library for image manipulation. It caches requests on both client-side and server-side.So basically, what it does is that it caches all the CSS and JS requests into a single request. And now the web page has to make only one request instead of multiple requests. This not only results in the reduction of the number of requests but also reduces server hop.Download link:

  1. Imagine

    This PHP library helps to optimize and reduce image size. You can say that you can use this library to manipulate image. For example, you can use Imagine to resize images, watermark an image, create a collage of images, access the metadata for image and manipulate it. The library has some advanced features like gamma correction, change to the negative, colour size, change brightness. You can work on a pixel by pixel, so your image will be pixel perfect.Create a composer.json file and paste the below code:

         "require": {
             "imagine/imagine": "~0.5.0"

    Now run: php composer.phar install

  1. Snappy

    This PHP library will help you to generate thumbnail, snapshot, or PDF using a URL or an HTML page. Snappy uses excellent WebKit based wkhtmltopdf and wkhtmltoimage which is available for OSX, Linux, and Windows. Therefore, in order to use a snappy library, you have to download wkhtmltopdf. Most people use this library for full webpage screenshot and automated screenshot testing. This library runs completely in headless mode, which means you do not need a separate display or a display service. The snappy library is being maintained by KNlabs and is looking for this library maintainers. So if you’re interested in maintaining the library, you can apply for it.

    Composer command: composer require knplabs/knp-snappy

  1. SRL-PHP or Simple Regex Library

    As you know everyone struggles with regular expression as they are hard to read and understand. SRL-PHP has predefined functions for each and every type of regex. The library is independent which means you can use it without worrying.SEL-PHP provides methods that can be chained together which results in forming readable RegEX rules. This library has a port for JavaScript and Python.Create a composer.json and paste the below code:

    "require": {
         "simpleregex/srl-php": "0.1.x-dev"

    Now run: composer install

  2. Stash

    This is another library for speeding up your code. Stash PHP caches the result of some expensive functions and codes. Some actions like complex database queries or calls to some external APIs take a lot of time and are used again and again. This is where Stash PHP comes in to play. Stash caches all the results and once the same query is called or the same API is called with the same parameters. Then stash sends the same results and reduces the loading time.

    Composer command: composer require tedivm/stash

  3. PHP VCR

    This library is based on VCR library. PHP VCR is a PHP library that saves cassettes of data. It helps in speeding up your code like stash. So you can record your own test suites for HTTP interactions and play them whenever you want to. PHP VCR stores the results of HTTP requests in small cassettes and replays them automatically for future tests.

    Composer command: composer require --dev php-vcr/php-vcr

  4. MINI

    This PHP library comes with many handy dandy functionalities. This is not a complete library like Laravel or CodeIgniter. So if you want to build a small web application and needs some of the features of a good framework, you can use this library. The library is very easy to understand and doesn’t make things complicated. It has inbuilt functionality to make AJAX requests, perform CRUD operations on the database without writing down any query and the best part is that MINI is completely independent.MINI has a smaller brother name TINY, which is similar to MINI but can be executed without any mod_rewrite. MINI2 is the big brother of MINI, which is simpler than MINI itself. MINI3 is the successor of MINI and has more functionalities than MINI.

    Download link:

  1. PURL

    A PHP library for working with URLs. You can use this PHP library to compose complex paths attribute, extract data from URL, manipulate URLs and recognize URLs in strings. The feature list includes path manipulation, query manipulation, fragment manipulation, extract URL, join URLs etc.

    Composer command: composer require jwage/purl


    So, you have created a very big PHP application now comes the documentation part. You might be very bad at grammar or would need to hire someone to write the documentation. This is where come into play. It automatically generates documentation that uses the simple file structure and markdown files to generate documentation on the generates 100% mobile responsive documentation, supports markdown tables, 4 themes built-in, SEO friendly URLs, uses bootstrap, and much more.

    Composer command: composer global require daux/

  3. InstaPHP

    This is a PHP library for accessing Instagram API. InstaPHP uses the Instagram API and provides an easy way to authenticate with Instagram API and access other all the other endpoints, images, users, likes, comments, and tags.Download link:

  4. Latitude

    You might be thinking that this PHP library is related to Geolocation. But no, Latitude is a zero-dependency library for building SQL queries using the functionalities of chaining functions. Latitude supports most of the query type and also works with the Postgres, SQL Server and other databases. Generate criteria, expressions, aliases, functions, ordering, identifiers, parameters, and lists.

    Composer command: composer require latitude/latitude

  5. PHP-ML

    So now you can work on machine learning with PHP? Here’s the PHP-ML or PHP Machine Learning library for you. You have created a bot wants to train your bot with different samples. The PHP-ML library offers a load of algorithms inbuilt. Some of the in-built algorithms are Apriori, SVC, k-nearest neighbour, Naïve Bayes, Decision tree, Bagging, Random Forest, AdaBoost, Adaline, Decision Stump, Perceptron, Logistic Regression, Least Square, SVR, Decision Tree Regressor, SVR, K-means, DBSCAN, Fuzzy C-Means and some 50+ other algorithms which is listed on their website.

    Composer command:composer require php-ai/php-ml

  6. Twig

    This is a simple, fast, and secure template language for PHP. The Twig library is both designers as well as developer-friendly. The key feature of Twig is that it compiles the template into plain optimized PHP code.Twig also has a sandbox mode to work on untrusted PHP code. This library is being used by menu open source projects like Drupal, Yii, Laravel, CodeIgniter and so on.

    Composer command: composer require "twig/twig:^2.0"

  7. Facebook SDK

    Well Facebook doesn’t need any introduction, right? Facebook SDK is a set of classes to connect to Facebook API. Facebook also has Graph API so you can use this SDK to connect to Graph API. It also allows mobile app developers to integrate Facebook within their mobile applications. Facebook SDK provides the user with the facility to transfer app event data from the app to Facebook. With app event data, users can accurately follow and measure the action taken by people using their apps.Using Facebook SDK the developers can include Facebook login functionality, content sharing and social plugins. For marketers, Facebook SDK allows them to send data from mobile applications to Facebook Ad library which is a must for marketing a mobile app.

    Composer command: composer require facebook/graph-sdk

  8. AWS SDK

    This is the official SDK from Amazon, to connect to their services. Personally, I have used AWS SDK for connecting to AWS S3 buckets for reading and writing objects. The documentation is very easy to understand and easy to use as well. You can connect to services like AWS Glacier, Dynamo DB, EC2 etc. The SDK is available for other languages like JS, Ruby, Python, Java etc.

    Composer command: composer require aws/aws-sdk-php

  9. Whoops

    This PHP library works as an error handler framework for PHP. It allows you to handle errors and exceptions throughout your web application. Whoops PHP library generates a better page for error instead of showing errors on a white page with black text. It also supports JSON and AJAX requests. The library has no dependency other than PHP. There are multiple handles provided by Whoops. Whenever something goes wrong, the error is handled by handlers and displayed on a very cool looking page. It has many different options for UI also. Whoops comes pre-loaded with Laravel 4, that is the reason why it has some beautiful looking error page.

    Composer command:  composer require filp/whoops

  10. uBench

    This is a PHP library for benchmarking. It allows you to check the execution time for a PHP script and other functionalities like memory usage, memory peak, time, start and end time. Create a composer.json and paste the below code:

         "require": {
             "devster/ubench": "~2.0.0"

    Now run composer command: composer install

  11. Rinvex Country

    As the name suggests, this PHP library is simple and lightweight for retrieving country details. Rinvex Country library not only includes retrieving the country list but also includes country-specific details like capital, ISO codes, dialling code, geodata, national currency, flag, emoji, latitude, longitude, region, sub-region, demonym, continent etc. And the best part is that it has no dependency other than PHP 7.0+.

    Composer command: composer require rinvex/countries

  12. Swap

    This library is for retrieving currency exchange rates from various sources like Fixer or currency layer and also caches the results. So if you want to fetch exchange rate for any day again, it’ll use from the cache. Which not only results in faster response but also reduces API hits.

    Composer Command: composer require php-http/curl-client nyholm/psr7 php-http/message florianv/swap

  13. Google OAuth library

    Google API uses the OAuth 2.0 protocol for authorization and authentication. OAuth 2 permits access to user accounts on an HTTP service, such as Facebook, GitHub and Digital Ocean for a limited time. It is an authorization framework that works by entrusting user authentication to the service that hosts user account and approves third-party applications to access the user accounts. It provides sanction flows for web, desktop and mobile applications. OAuth delineates four roles:-

    •  Resource Owner (User)
    • Client (Application)
    • Resource Server
    • Authorization Server

OAuth separates the role of the client from the resource owner by introducing an authorization layer. The use of OAuth over any protocol other than HTTP is beyond the scope.

Composer command: composer.phar require google/auth


  1. pChart

    This is a PHP library that allows the user to create anti-aliased charts or pictures directly from web servers. The user can display the result in the client browser, sent it by mail or insert it into pdfs. It offers object-oriented coding syntax and is fully compatible with the new web standards. Core features of pChart include native anti-aliasing, alpha transparency, shadow support, spline and cubic curves.It also has some extra functionalities like pSpring, barcode extensions, pCache, Sandbox engine, labels and image maps support, conditional formatting and visual effects. In order to reduce CPU time, speedup the web transaction, and improve user experience it provides pCache. The internal cache has rewritten entirely to make it more suitable to user needs and management.

    Download link:

  2. Services_JSON

    This class converts to and from JSON format. It has the following functions and methods:

    Services_JSON::decode It decodes a JSON string into  appropriate variable
    Services_JSON::encode It encodes an arbitrary variable into JSON format
    Services_JSON::Services_JSON It constructs a new JSON instance
    Services_JSON::reduce_string It reduces a string by removing leading and trailing comments and whitespaces.
    Services_JSON::name_value It is used in generating JSON formatted name-value pairs
    Services_JSON::utf162utf8 It converts a string from one UTF 16 char to one UTF 8 char.
    Services_JSON::utf82utf16 It converts a string from one UTF 8 char to one UTF 16 char.
    Service_JSON::isError This should just call PEAR::isError()

    Download link:

  1. PHP DB Class

    DBClass is a simple PHP database class using MySQL improved extension. This library allows the user to run SQL queries using a chain of functions. It uses object-oriented functionality of PHP and by default comes with SQL injection-proof. On using this library for MySQL queries, the users do not need to check for prepared statements over and over again. This library is packed with a debug mode as well. This functionality is extremely useful if there is an error or if the users want to check the quality of their codes.

    Download Link: