DEV Community

Cover image for PHP libraries and tools
Rubén Rubio
Rubén Rubio

Posted on

PHP libraries and tools

PHP possesses a rich ecosystem, with plenty of libraries and tools. Here is a list of them that I consider interesting, beyond any framework.

At the end, I included some useful checks for Composer and Symfony to execute on a CI pipeline.

Libraries

  • brick/math: Arbitrary-precision arithmetic library for PHP
  • openspout/openspout: Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
  • thecodingmachine/safe: All PHP functions, rewritten to throw exceptions instead of returning false
  • azjezz/psl: PHP Standard Library - a modern, consistent, centralized, well-typed, non-blocking set of APIs for PHP programmers
  • particle/validator: Particle\Validator is a validation library with an extremely clean API which makes validation fun!
  • league/tactician: A small, flexible command bus.
  • league/flysystem: Abstraction for local and remote filesystems
  • golem-ai/messenger-kit: This command simulates consumer failures and prints a timeline of the events. It lets you check whether your retry strategy configuration does what you expect it to.
  • swarrot/swarrot: A lib to consume message from any Broker
  • ronanguilloux/isocodes: PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Manufacturing Industry, Phone numbers & Zipcodes for many countries
  • php-units-of-measure/php-units-of-measure: A library for handling physical quantities and the units of measure in which they're represented.
  • rawr/t-regx: PHP regular expression brought up to modern standards.
  • mpratt/embera: A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
  • spatie/geocoder: Geocode addresses to coordinates
  • php-soap/wsdl-reader: A pure PHP wsdl metadata provider
  • phpro/soap-client: A general purpose SOAP client for PHP
  • eventsauce/backoff: Sophisticated back-off strategies for retrying operations.
  • pontedilana/php-weasyprint: PHP library allowing PDF generation or snapshot from an URL or an HTML page. Wrapper for Kozea/WeasyPrint
  • Parsers:
    • cuyz/valinor: PHP library that helps to map any input into a strongly-typed value object structure.
    • cerbero/json-parser: 🧩 Zero-dependencies lazy parser to read JSON of any dimension and from any source in a memory-efficient way.
    • yzen.dev/plain-to-class: Class-transformer to transform your data into a typed object
    • JanePHP: 🌱 Jane is a set of libraries to generate Models & API Clients based on JSON Schema / OpenAPI specs
  • Time:
  • Money:
    • brick/money: A money and currency library for PHP
    • moneyphp: PHP implementation of Fowler's Money pattern
  • Search:
    • schranz-search/seal: Search abstraction over different search engines written in PHP. Currently implemented Elasticsearch, Opensearch, Algolia, Meilisearch, RediSearch, Solr, Typesense.
    • loupe/loupe: A full text search engine with tokenization, stemming, typo tolerance, filters and geo support based on only PHP and SQLite.

Test libraries

Tools

Performance frameworks

  • Hyperf: 🚀 A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.
  • Flow PHP: Flow PHP - strongly typed data processing framework
  • PHPTokio: Use any async Rust library from PHP!

Composer tools

  • ComposerRequireChecker: A CLI tool to check whether a specific composer package uses imported symbols that aren't part of its direct composer dependencies
  • composer-unused: Show unused composer dependencies by scanning your code
  • composer-normalize: Provides a composer plugin for normalizing composer.json.

Security

CI checks

  • Lints (for Symfony):
    • PHP: find src public bin -name "*.php" -print0 | xargs -0 -n1 php -l
    • Container: bin/console lint:container
    • YAML: bin/console lint:yaml config src
    • Twig: bin/console lint:twig src
  • Symfony + Doctrine:
    • Deprecations: bin/console debug:container --deprecations (even if it fails, it returns 0 as exit code)
    • Doctrine schema: bin/console doctrine:schema:validate --skip-sync
  • Composer
    • Audit (The audit command checks for security vulnerability advisories for installed packages.): composer audit
    • Outdated (The outdated command shows a list of installed packages that have updates available, including their current and latest versions): composer outdated --minor-only --direct --strict
    • Validate (It will check if your composer.json is valid): composer validate --strict

Sources

This list is inspired (and based to some extent) by:

Top comments (8)

Collapse
 
roxblnfk profile image
Aleksei Gagarin

It's nice to see that there is no the unfunalize package on this list 🙂
By the way, buggregator/trap and buggregator/server could complement this list.

Collapse
 
rubenrubiob profile image
Rubén Rubio

I am way beyond pointless polemics nowadays :)

Thank you for your suggestion. I did not know buggregator, but it sure looks interesting. I will give it a try soon!

Collapse
 
leslieeeee profile image
Leslie

If you are a macOS user, ServBay.dev is worth to try. You don't need to spend some time or couple of days to setup anything. Just download it and you can use it immediately. You can run multiple PHP versions simultaneously and switch between them effortlessly.
Honestly, this tool has greatly simplified my PHP development and is definitely worth trying!

Collapse
 
rubenrubiob profile image
Rubén Rubio

Thank you for your comment! I did not about ServBay, but it looks pretty interesting.

I do not know if you are aware of PHPMonitor phpmon.app/

I have not used it myself, as I always use Docker, but it looks awesome too.

Collapse
 
jo1opedro profile image
João Pedro Ferreira Pedreira

what you think about: github.com/Respect/Validation for validation?

Collapse
 
rubenrubiob profile image
Rubén Rubio

I did not know about it, but it sure looks pretty good. Thank you for bringing it to my attention!

Collapse
 
andreagentil profile image
Andrea Gentil

Hi Ruben! Thank you for gathering this list 🙂. I suggest you add PHP Prefixer, an automated online service to apply prefixes to Composer dependencies.

Collapse
 
rubenrubiob profile image
Rubén Rubio

Thank you for your suggestion! Nonetheless, in this post, I am more focused in open source libraries.