Skip to content
Mark King edited this page Sep 25, 2026 · 12 revisions

Welcome to the php-alpm wiki!

This extension lets you drive Arch Linux's libalpm (the library behind pacman) from PHP: read pacman databases, inspect packages, and (carefully) run install/remove/upgrade transactions.

php-alpm is still 0.x. There is no backwards-compatibility guarantee until 1.0. AlpmTransaction in particular is the least battle-tested part of the extension — if you only need to read information out of a pacman database (AlpmHandle, AlpmDb, AlpmPkg), you should hit very few problems.

Requirements

  1. PHP >= 8.2
  2. libalpm >= 16.0 (pacman >= 7.1)

Building and installing

Get the code:

$ git clone https://github.com/markzz/php-alpm.git
$ cd php-alpm

If you're not on Arch Linux, you'll need to build and install pacman (which provides libalpm) first. install_pacman.sh in the repo root is what CI uses to do this on Ubuntu and is the best up-to-date reference for build dependencies; run it with a pacman git ref to build:

$ ./install_pacman.sh v7.1.0

Then build the extension the normal PHP extension way:

$ phpize
$ ./configure --enable-alpm
$ make
# make install

This gets you alpm.so in your PHP modules folder. Add extension=alpm.so to your php.ini to enable it.

Where to start

  • Classes — overview of every class the extension provides
  • Functions — the handful of top-level functions
  • Constants — ALPM_* constants used for siglevels, flags, etc.

If you're new to this, start with AlpmHandle — it's the object you create first and the one everything else hangs off of.

Contributing

Read CONTRIBUTING.md in the repo for the C coding style before sending patches. Sign off your commits (git commit -s) if you can. Fork on GitHub and open a pull request, or send git-formatted patches to mark.king@markzz.com — whichever's easier for you.

Stub definitions for IDE autocompletion live in stubs/alpm.php in the repo and are kept in sync with the extension on every release; they're a good quick-reference alongside this wiki.

Clone this wiki locally