PHPackages                             abdulbasset/nssm-php - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. abdulbasset/nssm-php

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

abdulbasset/nssm-php
====================

PHP Wrapper for nssm - the Non-Sucking Service Manager

v1.1.0(3mo ago)13MITPHPPHP ^8.3CI passing

Since Mar 10Pushed 3mo agoCompare

[ Source](https://github.com/Abdulbasset/nssm-php)[ Packagist](https://packagist.org/packages/abdulbasset/nssm-php)[ RSS](/packages/abdulbasset-nssm-php/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (5)Used By (0)

NSSM PHP
========

[](#nssm-php)

A lightweight PHP wrapper for [NSSM](https://nssm.cc/) (the Non-Sucking Service Manager). This package allows you to manage Windows services using PHP by providing a fluent interface to interact with the NSSM binary.

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

[](#installation)

You can install the package via composer:

```
composer require abdulbasset/nssm-php
```

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- [NSSM](https://nssm.cc/download) binary must be available in your system's PATH, or you can specify the path to the binary manually.

Usage
-----

[](#usage)

### Basic Service Management

[](#basic-service-management)

```
use Abdulbasset\NssmPhp\Nssm;

$nssm = new Nssm('MyService');

// Start the service
$nssm->start();

// Stop the service
$nssm->stop();

// Restart the service
$nssm->restart();
```

### Installing and Removing Services

[](#installing-and-removing-services)

```
use Abdulbasset\NssmPhp\Nssm;

$nssm = new Nssm('MyService');

// Install service (with application path and arguments)
// The bin() method sets the path to the executable (e.g., php.exe)
$nssm->bin('C:\path\to\your\app.exe')->install('arg1', 'arg2');

// Remove service
$nssm->remove();
```

### Configuring Service Parameters

[](#configuring-service-parameters)

You can set various service parameters using the `set` method. It provides a fluent interface to set multiple parameters at once:

```
use Abdulbasset\NssmPhp\Nssm;
use Abdulbasset\NssmPhp\Startup;
use Abdulbasset\NssmPhp\NssmSet;

$nssm = new Nssm('MyService');

$nssm->set(function (NssmSet $set) {
    $set->displayName('My Custom Service Name')
        ->description('This is a custom service managed by PHP')
        ->startup(Startup::Automatic)
        ->appDirectory('C:\path\to\app')
        ->output('C:\path\to\logs\stdout.log')
        ->error('C:\path\to\logs\stderr.log');
});
```

### Log Rotation

[](#log-rotation)

You can configure log rotation for stdout and stderr files. By default, enabling rotation will rotate files when the service starts or restarts.

```
use Abdulbasset\NssmPhp\Nssm;
use Abdulbasset\NssmPhp\NssmSet;
use Abdulbasset\NssmPhp\NssmRotation;

$nssm = new Nssm('MyService');

$nssm->set(function (NssmSet $set) {
    // Basic rotation (enables AppRotateFiles)
    $set->rotation();

    // Advanced rotation configuration
    $set->rotation(function (NssmRotation $rotation) {
        // Rotate every 1 hour (accepts seconds or DateInterval)
        $rotation->everySeconds(new \DateInterval('PT1H'));

        // Rotate when file size exceeds 1 MB (in bytes)
        $rotation->everyBytes(1024 * 1024);

        // Enable rotation while the service is running (online rotation)
        $rotation->online();
    });
});

// To disable rotation
$nssm->set(fn(NssmSet $set) => $set->rotation(false));
```

### Get Service Status

[](#get-service-status)

The `status()` method returns an instance of the `Abdulbasset\NssmPhp\Status` enum, or `null` if the status is unknown.

```
use Abdulbasset\NssmPhp\Nssm;
use Abdulbasset\NssmPhp\Status;

$nssm = new Nssm('MyService');
$status = $nssm->status();

if ($status === Status::Running) {
    echo "Service is running!";
}

// Convenient helper methods:
if ($status?->running()) { ... }
if ($status?->pending()) { ... } // Returns true for StartPending or StopPending
if ($status?->exists()) { ... }  // Returns true if the service exists (not NotFound)
```

### Full Example

[](#full-example)

Here's a comprehensive example of how to install, configure, and manage a Windows service (Running Octane Server for example):

```
use Abdulbasset\NssmPhp\Nssm;
use Abdulbasset\NssmPhp\NssmSet;
use Abdulbasset\NssmPhp\NssmRotation;
use Abdulbasset\NssmPhp\Startup;
use Abdulbasset\NssmPhp\Status;

$nssm = new Nssm('MyAppOctaneServer');

$nssm->bin(PHP_BINARY)
    ->install(
        base_path('artisan'),
        'octane:start',
        '--quiet',
        '--port:8000'
    )
    ->set(fn(NssmSet $set) => $set
        ->displayName(config('app.name') . ' Octane Server')
        ->description('High-performance HTTP server for Laravel using ' . config('octane.driver') . '.')
        ->startup(Startup::Delayed)
        ->appDirectory(base_path())
        ->error(storage_path('logs/octane-err.log'))
        ->output(storage_path('logs/octane-out.log'))
        ->rotation()// enable it on service start/restart
        ->rotation(false) // disable rotation
        ->rotation(function (NssmRotation $rotation) {
            $rotation
                ->online()
                ->everySeconds(\Carbon\CarbonInterval::minutes(2))
                ->everyBytes(64 * 1024);
        })
    );
```

### Custom NSSM Binary Path

[](#custom-nssm-binary-path)

If `nssm` is not in your system's PATH, you can specify its location during instantiation or using the `nssm()` method:

```
use Abdulbasset\NssmPhp\Nssm;

// During instantiation
$nssm = new Nssm('MyService', 'C:\path\to\nssm.exe');

// Or using the nssm() method
$nssm->nssm('C:\path\to\nssm.exe');
```

Testing
-------

[](#testing)

The package uses [Pest](https://pestphp.com/) for testing.

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance82

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~4 days

Total

4

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3628cdff9032bab6d7a604c8110e340b657223f1764a564eeedfbb0a0d1f3377?d=identicon)[Abdulbasset](/maintainers/Abdulbasset)

---

Top Contributors

[![Abdulbasset](https://avatars.githubusercontent.com/u/27578098?v=4)](https://github.com/Abdulbasset "Abdulbasset (7 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/abdulbasset-nssm-php/health.svg)

```
[![Health](https://phpackages.com/badges/abdulbasset-nssm-php/health.svg)](https://phpackages.com/packages/abdulbasset-nssm-php)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[sammyjo20/lasso

Lasso - Asset wrangling for Laravel made simple.

355390.6k](/packages/sammyjo20-lasso)[shopware/deployment-helper

Shopware deployment tools

19365.5k5](/packages/shopware-deployment-helper)[salahhusa9/laravel-updater

Laravel Updater is a simple yet powerful package for updater your Laravel applications. It makes it easy to upgrade your application to the latest version with just one command.

2166.5k](/packages/salahhusa9-laravel-updater)[drevops/git-artifact

Package artifact from your codebase in CI and push it to a separate git repo.

2133.8k](/packages/drevops-git-artifact)

PHPackages © 2026

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