This code does not work with version 7 of PHP! Currently I am not able to fix this. If you want to take over development or submit patches it is very welcome... Please contact me if you are interested.

I do not write PHP code since many years so it would be great to find a maintainer for this code.


This is the only extension for using PC/SC based smart cards with PHP5. It is a wrapper to the wonderful and free project by Ludovic Rousseau, PCSC-Lite, which is the middleware to access a smart card using SCard API (PC/SC). Since PCSC-Lite is compatible to the winscard API it should be possible to compile this extension using a Windows(R) operating system. Currently I only take focus on Linux environments.

Thanks are going to Johann Dantant! He provides a PC/SC extension for PHP since 2005 and I reused some of his code. He allowed me to relicense these parts under the terms of the PHP license so I could integrate PCSC-Lite natively into PHP.


I recommend to install the PECL extension the "PHP" way:

pecl install pcsc-alpha

You can install the latest version by downloading the sources and compile yourself too... :)

tar -xvf pcsc-0.3.1.tgz
cd pcsc-0.3.1
make install

After that you have all needed files in ./modules/


The extension currently provides the following API:


Returns the application $context to the PC/SC resource manager.


Returns TRUE if $context is valid or FALSE if $context is not valid.


Releases the application $context.


Returns an array of available readers or FALSE.

array(3) {
  string(26) "OMNIKEY CardMan 5x21 00 00"
  string(26) "OMNIKEY CardMan 5x21 00 01"
  string(76) "SCL01x Contactless Reader [SCL01x Contactless Reader] (21161009200722) 00 00"

scard_connect($context, "OMNIKEY CardMan 5x21 00 00");

Connects to a card. Returns the $connection to a reader or FALSE.


Returns the $connection to a reader or FALSE.


Disconnects the $connection to a card. Returns the TRUE if disconnecting was succesful or FALSE.

scard_transmit($connection, $apdu);

Returns the response $apdu as string or FALSE.


Returns the status or FALSE.



The code has successful been released to the official code repository ;)

You could get the code using the following command:

svn checkout pcsc


This code is licensed under the terms of the PHP License version 3.01. PCSC-Lite is licensed in a way where it is possible to integrate it native in the PHP environment.