A library to communicate with ZXTouch written in PHP
This library enables to communicate with ZXTouch Tweak in PHP language.
This library requires php 8.0 or higher. The recommended way to install ZXTouch-PHP is Composer.
$ composer require aquachocomint/zxtouch-phprequire 'vendor/autoload.php';
$zxtouch = new \zxtouch\ZXTouch("127.0.0.1"); //Connect to the device that is running ZXTouch
$coords = new \zxtouch\element\Coordinates(500, 750); //We will touch the screen at this point
//Touch a screen
$zxtouch->touch(new \zxtouch\element\touch\TouchDown(1, $coords));
usleep(800000); //Wait for 0.8 seconds
$zxtouch->touch(new \zxtouch\element\touch\TouchUp(1, $coords));
//But you can tap a screen without these codes. Just call `\zxtouch\ZXTouch::tap()` method. (required v1.2.0 or higher)
$zxtouch->getConnection()->disconnect(); //Disconnect from the deviceThis documentation doesn't show all the functions. To get more information, please see the source code as it is self-documented.
First, you need to create zxtouch\ZXTouch instance to control your device. You can create an instance like:
$zxtouch = new \zxtouch\ZXTouch("127.0.0.1"); //"127.0.0.1" is the ip address to connect the deviceYou can tap your device using the \zxtouch\ZXTouch::tap() method.
$point = new \zxtouch\element\Coordinates(20, 50); //We will tap this point
$zxtouch->tap($point);You can get the screen size information using the \zxtouch\ZXTouch::getScreenSize() method.
$screen = $zxtouch->getScreenSize(); //This will return \zxtouch\result\ScreenSizeResult
var_dump($screen->getWidth(), $screen->getHeight()); //It will print width and height information