PHPackages                             ritenn/rplidar-a1 - 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. ritenn/rplidar-a1

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

ritenn/rplidar-a1
=================

Rplidar A1 library.

00PHP

Since May 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ritenn/laravel-rplidar-a1)[ Packagist](https://packagist.org/packages/ritenn/rplidar-a1)[ RSS](/packages/ritenn-rplidar-a1/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel RPLIDAR-A1 driver
=========================

[](#laravel-rplidar-a1-driver)

This package contains driver for RPLIDAR-A1 by SLAMTEC created in PHP that can be accessed via simple PHP interface/facade. It doesn't contain a visual representation of the data (I'll add js package later).

Installation
------------

[](#installation)

1. Download package and install it via composer:

`composer require ritenn/rplidar-a1`

2. Enable package and compy config to your laravel installation

`php artisan vendor:publish --provider="Ritenn\RplidarA1\RplidarA1ServiceProvider" --force`

Basic usage / Example
---------------------

[](#basic-usage--example)

You can implement this library using Facade or Interface:

```
use Ritenn\RplidarA1\Interfaces\LidarCommandInterface;
use Ritenn\RplidarA1\Facades\LidarCommands;
use Illuminate\Support\Collection;

/**
 * @var LidarCommandInterface
 */
public $lidarCommands;

/**
 * Scan flag
 */
public $isRunningScan = false;

/**
* @param LidarCommandInterface $lidarCommands
 */
public function __construct(LidarCommandInterface $lidarCommands)
{
    $this->lidarCommands = $lidarCommands;
}

/**
 * @return bool
 */
public function startScan() : bool
{
    $this->lidarCommand->startProcess();
    // ...or facade - LidarCommands::startProcess(); etc.
    $this->lidarCommand->openPort();
    $this->lidarCommand->sendCommand('GET_HEALTH');

    /**
     * getData() will always return response from device
     * In this case, simply returns health status.
     */
    $data = $this->lidarCommand->getData();

    if ( ! is_null($data) && $data->get('status') === 'Good' )
    {
        $this->lidarCommand->runMotor();

        if ( ! $this->lidarCommand->sendCommand('SCAN') )
        {
            return false;
        }

        $this->isRunningScan = true;
    }

    return true;
}

/**
 * @return bool
 */
public function stopScan() : bool
{
    if ( $this->lidarCommand->sendCommand('STOP') )
    {
        $this->lidarCommand->stopMotor();
        $this->lidarCommand->closePort();
        $this->lidarCommand->stopProcess();
        $this->isRunningScan = false;

        return true;
    }

    return false;
}

/**
 * @return Collection|null
 */
public function getScanData() : ?Collection
{
    /**
     * If scan is running, getData() will keep updating collection with new data
     * as soon as packets are received and interpreted by background process.
     *
     * You should implement websockets on frontend to get updated data.
     */
     if ( $this->isRunningScan )
     {
         return $this->lidarCommand->getData();
     }

     return collect([]);
}
```

Commands list - sendCommand(string $command)
--------------------------------------------

[](#commands-list---sendcommandstring-command)

CommandResponse / DescriptionGET\_HEALTHStatus string and error hex code 0x0, if all is fineGET\_INFOModel number, firmware, hardware, serial numberSTOPExit the current state and enter the idle stateSCANMost basic scan mode (legacy), use express if possibleEXPRESS\_SCAN\_LEGACYBest performance, data is encapsulated in so called "cabins"How it works?
-------------

[](#how-it-works)

Everything starts at PHP web server (command center). When background process is started by web server, it starts to listen for other commands and also for data from rplidar device (if port is already opened). Background process is communicating with rplidar directly via USB/UART converter, which means that you don't need any C++ driver to make it works. All the data from device is translated to ready for use 360 deg angle/distance (cm) array and stored in shared memory. This solution makes it really flexible, because you can access it also in other programing languages, not only PHP.

#### *Notice*

[](#notice)

> *This package uses small c++ program to set/clear DTR (data transmission ready) signal, which is required to start/stop motor. I'm not aware of any better solution in PHP.*

[![how it works](rplidar_schema.jpeg)](rplidar_schema.jpeg)

### Supported scan modes

[](#supported-scan-modes)

- Legacy (Traditional mode) - old simple, but little messy mode. It's up to 4000 samples (2000 for A1)
- Express (Legacy) - recommended, up to 8000 sampes (4000 for A1)
- Extended Version - maybe in future.
- Dense Version - my device doesn't support this one. Your device might expect this when you call express (legacy). It has the same request packet, but different descriptor.

### Requirements

[](#requirements)

- This library was tested only on Linux ARM x64 (Raspbery Pi 4), therefore it is more then possible that it won't work on Windows.
- This library was tested with rplidar A1, firmware version 1.04.
- PHP 7.2+, 8.x recommended.
- Enabled exec function, it won't be possible to start background process and run motor without it.
- Knowledge about Linux permissions.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39996570?v=4)[ritenn](/maintainers/ritenn)[@ritenn](https://github.com/ritenn)

---

Top Contributors

[![ritenn](https://avatars.githubusercontent.com/u/39996570?v=4)](https://github.com/ritenn "ritenn (1 commits)")

### Embed Badge

![Health badge](/badges/ritenn-rplidar-a1/health.svg)

```
[![Health](https://phpackages.com/badges/ritenn-rplidar-a1/health.svg)](https://phpackages.com/packages/ritenn-rplidar-a1)
```

PHPackages © 2026

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