Download the PHP package ronanguilloux/php-gpio without Composer

On this page you can find all versions of the php package ronanguilloux/php-gpio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-gpio

php-gpio

php-gpio is a simple PHP library to play with the Raspberry PI's GPIO pins.

It provides simple tools such as reading & writing to pins.

Latest Stable Version Build Status Scrutinizer Code Quality SensioLabsInsight Total Downloads

Circuit snapshot

[UPDATE Fall 2014] Now compatible with both Raspberry Pi B Model & B+ Revision

Tl;dr

=> php-gpio-web: a simple example for you to play with Leds & PHP

GPIO

General Purpose Input/Output (a.k.a. GPIO) is a generic pin on a chip whose behavior (including whether it is an input or output pin) can be controlled (programmed) through software. The Raspberry Pi allows peripherals and expansion boards (such as the Rpi Gertboard) to access the CPU by exposing the inputs and outputs.

For further informations about the Raspberry Pi's GPIO capabilities, see docs & schemas at http://elinux.org/RPi_Low-level_peripherals.

For Raspbeery Pi's GPIO controlling LEDs, have a look at a sample complete circuit diagram for a single LED, with detailled explanations & schemas, here.

For Raspbeery Pi's GPIO controlling sensors, check the DS18B20 (temperature sensor) in action here

Hardware prerequisites

After having installed & wired your LED & resistor on a breadboard, add appropriate modules from the Linux Kernel:

For LEDs, enable the gpio module :

(see a complete circuit diagram for a single LED + explanations & schemas here)

For sensors, enable the appropriate sensor. By example for a DS18B20 1-Wire digital temperature sensor:

(see the DS18B20 in action on a Raspberry Pi here)

To load such kernel modules automatically at boot time, edit the /etc/modules file & add these two lines:

Installation

The recommended way to install php-gpio is through composer.

Just run these three commands to install it

Now you can add the autoloader, and you will have access to the library:

If you don't use neither Composer nor a ClassLoader in your application, just require the provided autoloader:

API Usage

The API usage requires sudo permissions.
To respect such permissions needs (say, for any web-related usage), see blinker file and the explanations below.

Understanding I/O permissions

Permissions make sense:

Such practices are regularly proposed on RPi forums, but they aren't security-aware & therefore not recommendable in an Internet environment. Instead, the good old /etc/sudoers file allow your linux users to execute single files with sudo permissions without password to type.

The blinker file solution ("one-file-to-blink-them-all")

In a PHP-based project, the API can only be used with sudo permissions. But there is a solution to avoid exposing your Raspbery Pi to security issues : Preparing & packaging inside an API client, in a single PHP file, the GPIO operation you need to run. In a hardware-based project, such operations are usualy few in number: blink a led, run a servomotor, etc. Such single PHP file containing your GPIO-related action can be called with determinated parameters from within your web-based application using exec() command :

Such one-single PHP file to act as an API client for one GPIO action makes easier to configure specific sudo permissions in your /etc/sudoers file, as you'll see below. If you have more hardware operations to run (say, a LED + a servomotor + 2-3 sensors), more dedicated API client files, with their own parameters, is also very OK.

As an example of such solution, we provide a simple blinker php file, executable from the shell & from within your web based app. To run this blinker with sudo permissions but without password inputting, just allow your www-data or your pi user to run the blinker script using exec(). With the solution provided below, only one blinker script is needed to manage all your leds, and your webserver application needs only one php file to be specified in /etc/sudoers.

This is the regular linux-file-permission-system way to do such things, not a dummy chmod 777 bullshit.

Edit your /etc/sudoers file:

Then add this two lines in your /etc/sudoers file :

Replace /path/to/the/blinker with your single API client PHP file.

The blinker file provided now has the sufficient permissions & is ready to use the GPIO API. You do not need to install apache2-suexec nor suPHP.

You can test the blinker file solution with the blinkerTest.php file provided here:

Test your blinker:

API Implementations

Some php-gpio api examples / demo :

Unit Tests

Running the full PhpUnit tests set over php-gpio requires a sudoable user, because of various gpio operations. Instead of installing phpunit, you can just download & use the single PhpUnit package. This can be easily done using cURL, to get the standalone PhpUnit's phar file:

PHP Quality

For PHP quality fans, and for my self coding improvement, I wrote a little script available in the ./bin directory I launch to check my PHP code: It produces various stats & metrics & improvements tips on the code.

Credits

License

php-gpio is released under the MIT License.
See the bundled LICENSE file for details.
You can find a copy of this software here: https://github.com/ronanguilloux/php-gpio


All versions of php-gpio with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ronanguilloux/php-gpio contains the following files

Loading the files please wait ....