diff --git a/.gitignore b/.gitignore index 20a939e..84fdd0e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/ -.idea/ \ No newline at end of file +.idea/ +install/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1315880..ae9f33a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,27 @@ language: php dist: trusty +os: + - linux + - windows + +matrix: + allow_failures: + - os: windows + php: - 5.5 - 5.6 - - hhvm - 7.0 + - 7.1 + - 7.2 + - 7.4 before_script: - composer install + - chmod 777 install.sh script: - - mkdir -p build/logs + - mkdir -p build/logs - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml test/ + - sh install.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a1aafe8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Matheus Marabesi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 744a62e..70d1341 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# arduino-php-wrapper +# arduino-php-wrapper (inspired by Johnny-Five JS) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/3d57a79cbf3245e0af61e9123fda26eb)](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://travis-ci.org/marabesi/arduino-php-wrapper.svg?branch=master)](https://travis-ci.org/marabesi/arduino-php-wrapper) @@ -9,9 +9,15 @@ 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 + +``` +composer require marabesi/arduino-php-wrapper +``` + ## Usage -to write date on Arduino serial just use the regular I/O functions in PHP such as **fwrite** or **file_put_contents** +To read data from Arduino serial just use the regular I/O functions in PHP such as **fread** or **file_get_contents** ``` php \Arduino\Wrapper::register(); @@ -22,6 +28,7 @@ print fread($resource, 1024); ``` Or if you prefer, you can use **file_get_contents** and get the same result + ``` php print file_get_contents('arduino://ttyUSB0'); ``` @@ -52,6 +59,7 @@ You can use in your project in a OOP style $writer = new Arduino\Writer(new Arduino\Wrapper()); $bytes = $writer->out('ttyUSB0', 'from oop'); ``` + ### Reading data ``` php @@ -65,4 +73,16 @@ while (true) { ## Improvements -As you can see is really simple and we can improve it much more as the sensors are identified +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) + +[![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 - Nerdzão day #1](https://www.slideshare.net/marabesi/introduction-to-iot-and-php-nerdzao-day-1) + +[![SlideShare](https://img.shields.io/badge/slides-SlideShare-brightgreen.svg)]( +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://img.shields.io/badge/slides-SlideShare-brightgreen.svg)]( +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) diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..70c9c6a --- /dev/null +++ b/install.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir install +cd install && composer require marabesi/arduino-php-wrapper --no-interaction -vvv pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy