{"id":16461733,"url":"https://github.com/marabesi/arduino-php-wrapper","last_synced_at":"2025-10-15T12:44:33.161Z","repository":{"id":62523656,"uuid":"61247638","full_name":"marabesi/arduino-php-wrapper","owner":"marabesi","description":"Simple wrapper to connect with Arduino","archived":false,"fork":false,"pushed_at":"2020-10-04T10:34:40.000Z","size":625,"stargazers_count":22,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T22:08:01.167Z","etag":null,"topics":["arduino-php-wrapper","arduino-serial","iot","oop","php","wrapper"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marabesi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-15T23:27:44.000Z","updated_at":"2024-06-08T19:57:03.000Z","dependencies_parsed_at":"2022-11-02T14:01:11.400Z","dependency_job_id":null,"html_url":"https://github.com/marabesi/arduino-php-wrapper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marabesi%2Farduino-php-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marabesi%2Farduino-php-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marabesi%2Farduino-php-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marabesi%2Farduino-php-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marabesi","download_url":"https://codeload.github.com/marabesi/arduino-php-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244745681,"owners_count":20503044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino-php-wrapper","arduino-serial","iot","oop","php","wrapper"],"created_at":"2024-10-11T11:09:11.143Z","updated_at":"2025-10-15T12:44:28.109Z","avatar_url":"https://github.com/marabesi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# arduino-php-wrapper (inspired by Johnny-Five JS)\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3d57a79cbf3245e0af61e9123fda26eb)](https://www.codacy.com/app/matheus-marabesi/arduino-php-wrapper?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=marabesi/arduino-php-wrapper\u0026utm_campaign=badger)\n[![Build Status](https://travis-ci.org/marabesi/arduino-php-wrapper.svg?branch=master)](https://travis-ci.org/marabesi/arduino-php-wrapper)\n[![Latest Stable Version](https://poser.pugx.org/marabesi/arduino-php-wrapper/v/stable)](https://packagist.org/packages/marabesi/arduino-php-wrapper)\n[![Total Downloads](https://poser.pugx.org/marabesi/arduino-php-wrapper/downloads)](https://packagist.org/packages/marabesi/arduino-php-wrapper)\n[![composer.lock](https://poser.pugx.org/marabesi/arduino-php-wrapper/composerlock)](https://packagist.org/packages/marabesi/arduino-php-wrapper)\n\nIf you are wondering how to control the Arduino serial port via PHP, here is the solution. \nThe **arduino://** wrapper is a easy and straightforward way to write and read data from Arduino.\n\n## Install\n\n```\ncomposer require marabesi/arduino-php-wrapper\n```\n\n## Usage\n\nTo read data from Arduino serial just use the regular I/O functions in PHP such as **fread** or **file_get_contents**\n\n``` php\n\\Arduino\\Wrapper::register();\n\n//reads data from Arduino\n$resource = fopen('arduino://ttyUSB0', 'r+');\nprint fread($resource, 1024);\n```\n\nOr if you prefer, you can use **file_get_contents** and get the same result\n\n``` php\nprint file_get_contents('arduino://ttyUSB0');\n```\n\nTo write data in the Arduino serial is as easy as it could be\n\n``` php\n\\Arduino\\Wrapper::register();\n\n//writes data to Arduino\n$resource = fopen('arduino://ttyUSB0', 'r+');\nprint fwrite('hello Arduino');\n```\n\n``` php\n\\Arduino\\Wrapper::register();\n\nprint file_put_contents('arduino://hello Arduino');\n```\n\n## OOP\n\nYou can use in your project in a OOP style\n\n### Sending data\n\n``` php\n$writer = new Arduino\\Writer(new Arduino\\Wrapper());\n$bytes = $writer-\u003eout('ttyUSB0', 'from oop');\n```\n\n### Reading data\n\n``` php\n$arduino = new \\Arduino\\Wrapper();\n\n$writer = new \\Arduino\\Reader($arduino);\nwhile (true) {\n    print $writer-\u003efrom('/dev/cu.usbmodem1411');\n}\n```\n\n## Improvements\n\nAs you can see is really simple and we can improve it much more as the sensors are identified.\n\n- Prevent arduino from reload everytime a request is made by PHP\n\n## Slides (talks based on this lib)\n\n[![SlideShare](https://img.shields.io/badge/slides-SlideShare-brightgreen.svg)](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)\n\n[![SlideShare](https://img.shields.io/badge/slides-SlideShare-brightgreen.svg)](\nhttps://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)\n\n[![SlideShare](https://img.shields.io/badge/slides-SlideShare-brightgreen.svg)](\nhttps://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)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarabesi%2Farduino-php-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarabesi%2Farduino-php-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarabesi%2Farduino-php-wrapper/lists"}