laminas-ldap

A PHP library for binding, searching, and modifying entries in an LDAP directory.

Library
Composer
v2.20.0
7stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
47/100Fair
Development Activity60
Maintenance40
Community28
Maturity60
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
63/100Good
Architecture72
Code Quality74
Innovation50
Learning Curve55

laminas-ldap wraps PHP’s native ext-ldap functions in an object-oriented API for working with LDAP directories such as Active Directory or OpenLDAP. It covers connection/binding, filter construction, entry search and iteration, node/tree manipulation, and LDIF encoding, and is part of the Laminas project (the community-maintained successor to Zend Framework).

What You Get

  • An Ldap connection/bind class wrapping ext-ldap with configurable options (host, port, bind DN, credentials)
  • A composable Filter API (AndFilter, OrFilter, NotFilter, MaskFilter, StringFilter) for building LDAP search filters without manual string escaping
  • Node and Collection abstractions for reading and iterating LDAP directory entries and subtrees
  • LDIF encoding support via Ldif\Encoder for import/export of directory data
  • A dedicated exception hierarchy (LdapException, InvalidArgumentException, BadMethodCallException) for structured error handling

Common Use Cases

  • Authenticating application users against a corporate Active Directory or OpenLDAP server
  • Searching and paging through directory entries (users, groups, org units) with composed filter objects
  • Synchronizing or provisioning directory entries (create/update/delete) from an internal admin tool
  • Exporting or importing directory data in LDIF format for backups or bulk directory changes

Under The Hood

Architecture: The library centers on the Ldap class as the connection/session object, with Filter implementing a composite pattern (AbstractFilter/AbstractLogicalFilter base classes) so filters combine via and()/or()/not(), while Node and Collection wrap raw ext-ldap result arrays into iterable, attribute-aware objects (RootDse, Schema as specialized node types). Tech Stack: PHP 8.2–8.5, requiring the ext-ldap extension, with dev-only dependencies on other Laminas components (laminas-config, laminas-eventmanager, laminas-stdlib) and Symfony console/filesystem/string for tooling — the runtime dependency surface is otherwise just PHP itself. Code Quality: The repo runs PHPUnit (11.x) and Psalm static analysis (with a maintained psalm-baseline.xml) under a documented CI workflow, enforces laminas-coding-standard, and structures tests under a parallel test/ tree mirroring src/, indicating disciplined ongoing maintenance despite the component’s small user base. API Design: The filter-builder API keeps LDAP query construction type-safe and composable rather than string-concatenated, and exceptions implement a shared ExceptionInterface so callers can catch broadly or narrowly — the tradeoff is a steeper initial learning curve than raw ldap_* calls for developers unfamiliar with LDAP concepts like DNs and object classes.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search