pInkLevel is provided as source tarball. You can download the latest version from the website menu.
In order to compile it you will need :
- a working gcc installation
- libinklevel installed on your system (with development headers)
- a development installation of PHP (version > 5.2) with headers
To build run these commands:
You will probably need to be root to run install target.
The php module need to have read/write access to your printer device in order to get ink level. So you must add your webserver user in the right group (usually lp) to have access to the device.
pInkLevel module provide two classes. pInkLevel which is the main class to access ink level from your printer and pInkLevelException which is the exception class for handling errors generated by pInkLevel methods.
Static methods (these methods does not need an instance to be used):
In case of error, all these methods throw an instance of pInkLevelException class which is defined as:Examples
First example is simple xml file generation based on pInkLevel class
The result looks like:
This more complete example use the GD module to generate a graphical representation of two cartridge, one in black and one in three base colors. The generated image represent the ink level remaining in the cartridge. This example is not generic. You must adapt it to your printer (or write something more generic and publish it :))
Here's a screenshot of the output page:
inklevel.php: This script instanciate the pInkLevel object and show the cartridge image
cartridge.php: This script generate a png image with GD. This script use pInkLevel class to test the type of cartridge (to show colors for COLOR cartridge and black for other), and retrieve the name of the cartridge