You are not logged in.

#1 2017-03-25 02:46:30

markzz
Member
From: Michigan, United States
Registered: 2013-06-08
Posts: 89
Website

php-alpm: A PHP Extension For Pacman/ALPM

Project page: https://github.com/markzz/php-alpm
AUR page: https://aur.archlinux.org/packages/php-alpm/

php-alpm is a PHP extension so that libalpm (the library behind pacman) is accessible through PHP. It is mainly based on remy's pyalpm for Python.

Currently, it is still a work in progress (the master branch leaks memory like hell), but any tagged releases should work without much issue. Of course if you find a problem, let me know.

I am very interested in what my fellow PHP-using Archers think of it so far.

How to use it

Although incomplete, the beginnings of documentation are at https://github.com/markzz/php-alpm/wiki.

Here is a quick example on how to list all packages are installed on your system (basically a pacman -Q):

<?php
$h = new AlpmHandle("/", "/var/lib/pacman");
$localdb = $h->get_localdb();
$installed_pkgs = $localdb->pkgcache;

foreach ($installed_pkgs as $pkgname) {
    $pkg = $localdb->get_pkg($pkgname);
    echo $pkg->name . " " . $pkg->version . "\n";
}

Which outputs (on my system):

a52dec 0.7.4-9
aalib 1.4rc5-12
abs 2.4.4-2
accerciser 3.22.0-2
accountsservice 0.6.43-1
acl 2.2.52-3
acpi 1.7-1
acpid 2.0.28-1
adwaita-icon-theme 3.22.0+1+g58cd459e-1
aisleriot 3.22.1-1
...

Last edited by markzz (2017-03-25 03:40:57)


I don't want to work.  I want to bang on the drum all day.

Offline

Board footer

Powered by FluxBB