Download the PHP package remithefox/php-gpio without Composer

On this page you can find all versions of the php package remithefox/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

remithefox/php-gpio

PHP library which provide class for GPIO

Installation

Composer

Usage

At first make sure user has permission to use GPIO. Standard Raspbian configuration users in group GPIO have that permission.

Pin

Create RemiTheFox\PhpGPIO\Pin object to open GPIO pin.

Constructor parameters:

no. type name required default description
1 integer $pinNumber Yes (none) BCM pin number
2 string $direction No 'in' pin direction 'in' or 'out'
3 bool $force No false forces when pin is occupied
4 int $timeout No 10000 export timeout in microseconds
5 bool $autorelease No true pin will be released after unset or lost the last reference
6 string $devicePath No '/sys/class/gpio/' device path (almost sure you should leave it default, it's for testing)

Constructor throws:

Example:

Reading

To read pin state use getValue() method.

Method getValue() can throw:

Method getValue() returns true for logic high and false for logic low.

Example:

Writing

To write pin state (in output mode) use setValue() method.

setValue() method parameters:

no. type name required default description
1 bool $value Yes (none) new value

Method setValue() throws:

Method setValue() returns $this

Example:

Changing direction

To change pin direction use setDirection() method.

setDirection() method parameters:

no. type name required default description
1 string $direction Yes (none) new pin direction 'in' or 'out'

Method setDirection() throws:

Method setDirection() returns $this

Example:

Note: Please be careful with changing directions. If both devices are in output mode at the same time, it can short circuit and cause damages. I highly recommend avoiding direction changes. Otherwise make sure it's not possible for both devices to be in output mode at the same time.

Checking direction

To check pin direction use one of following methods: getDirection(), isInput(), isOutput()

method type input mode result output mode result
getDirection() string 'in' 'out'
isInput() bool true false
isOutput() bool false true

ParallelDataBus

To send data by parallel bus you can use RemiTheFox\PhpGPIO\ParallelDataBus object.

Constructor parameters:

no. type name required default description
1 PinInterface[] $pins Yes (none) Array of pins
2 string $direction No 'in' pin direction 'in' or 'out'

Constructor throws:

Example:

Yup it's too long. You can use factory method to make it short.

Reading

To read value on bus use getValue() method.

Method getValue() throws:

Method getValue() returns unsigned integer value in range from 0 to 2n-1

Example:

Writing

To write bus value (in output mode) use setValue() method.

setValue() method parameters:

no. type name required default description
1 int $value Yes (none) new value (value should be in range from 0 to 2n-1)

Method setValue() throws:

Method setValue() returns $this

Example:

Changing direction

To change bus direction use setDirection() method. This method changes direction of all pins.

setDirection() method parameters:

no. type name required default description
1 string $direction Yes (none) new pin direction 'in' or 'out'

Method setDirection() throws:

Method setDirection() returns $this

Example:

Note: Please be careful with changing directions. If both devices are in output mode at the same time, it can short circuit and cause damages. I highly recommend avoiding direction changes. Otherwise make sure it's not possible for both devices to be in output mode at the same time.

Checking direction

To check pin direction use one of following methods: getDirection(), isInput(), isOutput()

method type input mode result output mode result
getDirection() string 'in' 'out'
isInput() bool true false
isOutput() bool false true

Factory

createParallelDataBus()

To create ParallelDataBus in the simpler way, you can use method Factory::createParallelDataBus().

no. type name required default description
1 int[] $pinNumbers Yes (none) array of BCM pin numbers
2 string $direction No 'in' pin direction 'in' or 'out'
3 bool $force No false forces when pin is occupied
4 int $timeout No 10000 export timeout in microseconds
5 bool $autorelease No true pin will be released after unset or lost the last reference
6 string $devicePath No '/sys/class/gpio/' device path (almost sure you should leave it default, it's for testing)

Method Factory::createParallelDataBus() throws:

Method Factory::createParallelDataBus() returns ParallelDataBus.

Example:

Exceptions

All exceptions are in namespace RemiTheFox\PhpGPIO\Exception and extends abstract class RemiTheFox\PhpGPIO\Exception.

ExportTimeout

ExportTimeout will be thrown when GPIO pin export time limit will be exceeded.

GpioNotFound

GpioNotFound will be thrown when GPIO is not found in system.

IOError

IOError will be thrown on any input/output error.

InvalidDirection

InvalidDirection will be thrown when direction will be different than 'in' or 'out'.

OutOfRange

OutOfRange will be thrown when trying to write value out of range from 0 to 2n-1 on ParallelDataBus.

PermissionDenied

PermissionDenied will be thrown when user does not have permission to use GPIO.

PinArrayExpected

PinArrayExpected will be thrown when ParallelDataBus gets something other than array of pins in first parameter of constructor.

PinOccupied

PinOccupied will be thrown when chosen pin is occupied (is exported) and $force flag is false.

WriteOnInputMode

WriteOnInputMode will be thrown when trying to write value on GPIO element on input mode.

long text? ASCII-fox


All versions of php-gpio with dependencies

PHP Build Version
Package Version
No informations.
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 remithefox/php-gpio contains the following files

Loading the files please wait ....