PHPackages                             marabesi/arduino-php-wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. marabesi/arduino-php-wrapper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

marabesi/arduino-php-wrapper
============================

v1.0.0(8y ago)211265PHPCI failing

Since Aug 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/marabesi/arduino-php-wrapper)[ Packagist](https://packagist.org/packages/marabesi/arduino-php-wrapper)[ RSS](/packages/marabesi-arduino-php-wrapper/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (2)Versions (1)Used By (0)

arduino-php-wrapper (inspired by Johnny-Five JS)
================================================

[](#arduino-php-wrapper-inspired-by-johnny-five-js)

[![Codacy Badge](https://camo.githubusercontent.com/29279c4aa9501632e452055355d3515433e0781b5750e496c69d63bb418400f7/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3364353761373963626633323435653061663631653931323366646132366562)](https://www.codacy.com/app/matheus-marabesi/arduino-php-wrapper?utm_source=github.com&utm_medium=referral&utm_content=marabesi/arduino-php-wrapper&utm_campaign=badger)[![Build Status](https://camo.githubusercontent.com/b466320384ad83ab5179d9742b2a270f0e9aaabe2839e00dc4a2848380c985f2/68747470733a2f2f7472617669732d63692e6f72672f6d617261626573692f61726475696e6f2d7068702d777261707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/marabesi/arduino-php-wrapper)[![Latest Stable Version](https://camo.githubusercontent.com/847fe7c8f6d11cfea6e5c9b486ae1149ceed8d8de4f4801467760d34a5e7508b/68747470733a2f2f706f7365722e707567782e6f72672f6d617261626573692f61726475696e6f2d7068702d777261707065722f762f737461626c65)](https://packagist.org/packages/marabesi/arduino-php-wrapper)[![Total Downloads](https://camo.githubusercontent.com/58d2bd262ade9cc8cad32e896551b4aa625aa0043a9bb560b13defdaf60fcd53/68747470733a2f2f706f7365722e707567782e6f72672f6d617261626573692f61726475696e6f2d7068702d777261707065722f646f776e6c6f616473)](https://packagist.org/packages/marabesi/arduino-php-wrapper)[![composer.lock](https://camo.githubusercontent.com/d15e5f7be447c459a5995234c6b8d0b793dd8e8151fb48fc736ee83265f3b1d5/68747470733a2f2f706f7365722e707567782e6f72672f6d617261626573692f61726475696e6f2d7068702d777261707065722f636f6d706f7365726c6f636b)](https://packagist.org/packages/marabesi/arduino-php-wrapper)

If you are wondering how to control the Arduino serial port via PHP, here is the solution. The **arduino://** wrapper is a easy and straightforward way to write and read data from Arduino.

Install
-------

[](#install)

```
composer require marabesi/arduino-php-wrapper

```

Usage
-----

[](#usage)

To read data from Arduino serial just use the regular I/O functions in PHP such as **fread** or **file\_get\_contents**

```
\Arduino\Wrapper::register();

//reads data from Arduino
$resource = fopen('arduino://ttyUSB0', 'r+');
print fread($resource, 1024);
```

Or if you prefer, you can use **file\_get\_contents** and get the same result

```
print file_get_contents('arduino://ttyUSB0');
```

To write data in the Arduino serial is as easy as it could be

```
\Arduino\Wrapper::register();

//writes data to Arduino
$resource = fopen('arduino://ttyUSB0', 'r+');
print fwrite('hello Arduino');
```

```
\Arduino\Wrapper::register();

print file_put_contents('arduino://hello Arduino');
```

OOP
---

[](#oop)

You can use in your project in a OOP style

### Sending data

[](#sending-data)

```
$writer = new Arduino\Writer(new Arduino\Wrapper());
$bytes = $writer->out('ttyUSB0', 'from oop');
```

### Reading data

[](#reading-data)

```
$arduino = new \Arduino\Wrapper();

$writer = new \Arduino\Reader($arduino);
while (true) {
    print $writer->from('/dev/cu.usbmodem1411');
}
```

Improvements
------------

[](#improvements)

As you can see is really simple and we can improve it much more as the sensors are identified.

- Prevent arduino from reload everytime a request is made by PHP

Slides (talks based on this lib)
--------------------------------

[](#slides-talks-based-on-this-lib)

[![SlideShare](https://camo.githubusercontent.com/b0e2e8ce6241a0d9e976da4bacbe26037bb544e968c5c419d4f1c8e15b32b9c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c696465732d536c69646553686172652d627269676874677265656e2e737667)](https://www.slideshare.net/marabesi/introduction-to-iot-and-php-nerdzao-day-1) [Introduction to IoT and PHP - Nerdzão day #1](https://www.slideshare.net/marabesi/introduction-to-iot-and-php-nerdzao-day-1)

[![SlideShare](https://camo.githubusercontent.com/b0e2e8ce6241a0d9e976da4bacbe26037bb544e968c5c419d4f1c8e15b32b9c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c696465732d536c69646553686172652d627269676874677265656e2e737667)](https://www.slideshare.net/marabesi/iot-powered-by-php-and-streams-phpexperience2017) [IoT powered by PHP and streams - PHPExperience2017](https://www.slideshare.net/marabesi/iot-powered-by-php-and-streams-phpexperience2017)

[![SlideShare](https://camo.githubusercontent.com/b0e2e8ce6241a0d9e976da4bacbe26037bb544e968c5c419d4f1c8e15b32b9c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c696465732d536c69646553686172652d627269676874677265656e2e737667)](https://www.slideshare.net/marabesi/controll-your-house-with-the-elephpant-phpconf2016) [Control your house with the elePHPant - PHPConf2016](https://www.slideshare.net/marabesi/controll-your-house-with-the-elephpant-phpconf2016)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 94.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3189d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69de2ef36dc524f31c69abecc34ee2fd38126eb47184d1c07ebcc75f87a7a81c?d=identicon)[marabesi](/maintainers/marabesi)

---

Top Contributors

[![marabesi](https://avatars.githubusercontent.com/u/2129872?v=4)](https://github.com/marabesi "marabesi (33 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")[![mrprompt](https://avatars.githubusercontent.com/u/166088?v=4)](https://github.com/mrprompt "mrprompt (1 commits)")

---

Tags

arduino-php-wrapperarduino-serialiotoopphpwrapper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marabesi-arduino-php-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/marabesi-arduino-php-wrapper/health.svg)](https://phpackages.com/packages/marabesi-arduino-php-wrapper)
```

###  Alternatives

[wythe/logistics

查询快递物流信息

3041.6k1](/packages/wythe-logistics)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
