PHPackages                             nubs/sensible - 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. nubs/sensible

ActiveLibrary

nubs/sensible
=============

A library for finding sensible user programs, like editor, pager, and browser.

v0.5.0(9y ago)07.2k[2 issues](https://github.com/nubs/sensible/issues)1MITPHPPHP ~5.6 || ~7.0

Since May 29Pushed 8y ago2 watchersCompare

[ Source](https://github.com/nubs/sensible)[ Packagist](https://packagist.org/packages/nubs/sensible)[ RSS](/packages/nubs-sensible/feed)WikiDiscussions master Synced 1mo ago

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

sensible
========

[](#sensible)

A PHP library for finding sensible user programs, like editor, pager, and browser.

[![Build Status](https://camo.githubusercontent.com/8cd3337fc3c1347b876b5271de38ffae8a3a6f45f84e5dda2f31e30f97e071e2/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6e7562732f73656e7369626c652e7376673f7374796c653d666c6174)](https://travis-ci.org/nubs/sensible)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/914b91d54eb1eac1f5611eaaa774c98b66a0aa9f77685822d9ca6efe69f20711/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e7562732f73656e7369626c652e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/nubs/sensible/)[![Code Coverage](https://camo.githubusercontent.com/fa527b820555c9c43e758024c41908ac617cbbcb0c6dd1b762bcce255eb46481/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6e7562732f73656e7369626c652e7376673f7374796c653d666c6174)](https://coveralls.io/r/nubs/sensible)

[![Latest Stable Version](https://camo.githubusercontent.com/32e57dc6c660514895372525be3158fe8b26b39151b684742b64a73b2155c5ce/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e7562732f73656e7369626c652e7376673f7374796c653d666c6174)](https://packagist.org/packages/nubs/sensible)[![Total Downloads](https://camo.githubusercontent.com/a7cce094825cdab1532676a3d3af714319b0f2c09c04ef5a11d8cd58d4d9692f/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e7562732f73656e7369626c652e7376673f7374796c653d666c6174)](https://packagist.org/packages/nubs/sensible)[![License](https://camo.githubusercontent.com/c4746fdb7390258d98cc16c8c720a228524117ee8732402aefce2e01c5950d36/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e7562732f73656e7369626c652e7376673f7374796c653d666c6174)](https://packagist.org/packages/nubs/sensible)

[![Dependency Status](https://camo.githubusercontent.com/9231d4f2b7532b667637c39cf2e022fe7046a1b90e003f3cc497fe7e7c18c4b4/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3533383636643730313463313538393563623030303035332f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/53866d7014c15895cb000053)

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

[](#requirements)

This library requires PHP 5.6, or newer.

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

[](#installation)

This package uses [composer](https://getcomposer.org) so you can just add `nubs/sensible` as a dependency to your `composer.json` file or execute the following command:

```
composer require nubs/sensible
```

Supported Program Types
-----------------------

[](#supported-program-types)

This library supports opening a text editor (like vim), a pager (like more), and a browser (like firefox).

Program Factories
-----------------

[](#program-factories)

The recommended way to initialize one of the supported program loaders is to use the included factories.

### Browser Factory

[](#browser-factory)

The browser factory uses a command locator (via [which](https://github.com/nubs/which)) to determine which browsers are available. The default list of browsers is

- sensible-browser
- firefox
- chromium-browser
- chrome
- elinks

A simple example for creating a browser object:

```
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$browserFactory = new Nubs\Sensible\CommandFactory\BrowserFactory(
    $commandLocatorFactory->create()
);
$browser = $browserFactory->create();
```

If you want to override the default list of browsers:

```
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$browserFactory = new Nubs\Sensible\CommandFactory\BrowserFactory(
    $commandLocatorFactory->create(),
    ['my-favorite-browser', 'some-fallback-browser']
);
$browser = $browserFactory->create();
```

### Editor Factory

[](#editor-factory)

The editor factory uses your `EDITOR` environment variable if set, otherwise it uses a command locator (via [which](https://github.com/nubs/which)) to determine which editors are available. The default list of editors is

- sensible-editor
- nano
- vim
- ed

A simple example for creating a editor object:

```
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$editorFactory = new Nubs\Sensible\CommandFactory\EditorFactory(
    $commandLocatorFactory->create()
);
$editor = $editorFactory->create();
```

If you want to override the default list of editors:

```
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$editorFactory = new Nubs\Sensible\CommandFactory\EditorFactory(
    $commandLocatorFactory->create(),
    ['my-favorite-editor', 'some-fallback-editor']
);
$editor = $editorFactory->create();
```

### Pager Factory

[](#pager-factory)

The pager factory uses your `PAGER` environment variable if set, otherwise it uses a command locator (via [which](https://github.com/nubs/which)) to determine which pagers are available. The default list of pagers is

- sensible-pager
- less
- more

A simple example for creating a pager object:

```
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$pagerFactory = new Nubs\Sensible\CommandFactory\PagerFactory(
    $commandLocatorFactory->create()
);
$pager = $pagerFactory->create();
```

If you want to override the default list of pagers:

```
$commandLocatorFactory = new Nubs\Which\LocatorFactory\PlatformLocatorFactory();
$pagerFactory = new Nubs\Sensible\CommandFactory\PagerFactory(
    $commandLocatorFactory->create(),
    ['my-favorite-pager', 'some-fallback-pager']
);
$pager = $pagerFactory->create();
```

Using the programs
------------------

[](#using-the-programs)

Once you've created the program type with its strategy for locating the sensible command for the user, you can use it to work with files/data/etc.

### Browser

[](#browser)

A browser can be executed to load a supported URI. For example:

```
$browser->viewURI(
    new Symfony\Component\Process\ProcessBuilder(),
    'http://www.google.com'
);
```

### Editor

[](#editor)

The editor can be used to edit files. For example:

```
$process = $editor->editFile(
    new Symfony\Component\Process\ProcessBuilder(),
    '/path/to/a/file'
);
if ($process->isSuccessful()) {
    // continue
}
```

There is also a convenient shorthand for editing a string in an editor by means of a temporary file. For example:

```
$updatedMessage = $editor->editData(
    new Symfony\Component\Process\ProcessBuilder(),
    'a message'
);
```

This will return the input unaltered if the process does not exit successfully.

### Pager

[](#pager)

The pager passes the file or string to the configured pager for convenient viewing. For example, for a file source:

```
$process = $pager->viewFile(
    new Symfony\Component\Process\ProcessBuilder(),
    '/path/to/a/file'
);
```

Or for a string source:

```
$process = $pager->viewData(
    new Symfony\Component\Process\ProcessBuilder(),
    'a message'
);
```

CLI Interface
-------------

[](#cli-interface)

There is also a CLI interface for Linux systems that imitates Ubuntu's `sensible-*` commands. It is available as [`nubs/sensible-cli`](https://github.com/nubs/sensible-cli).

License
-------

[](#license)

sensible is licensed under the MIT license. See [LICENSE](LICENSE) for the full license text.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% 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 ~181 days

Total

5

Last Release

3647d ago

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.2

v0.4.0PHP ~5.4

v0.5.0PHP ~5.6 || ~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/43e7568db49cb140fe4deef1e585de0874e2a962a1140662003a5c070f536879?d=identicon)[nubs](/maintainers/nubs)

---

Top Contributors

[![nubs](https://avatars.githubusercontent.com/u/57673?v=4)](https://github.com/nubs "nubs (57 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

browserpageruserenvironmenteditorsensible

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nubs-sensible/health.svg)

```
[![Health](https://phpackages.com/badges/nubs-sensible/health.svg)](https://phpackages.com/packages/nubs-sensible)
```

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[sebastian/environment

Provides functionality to handle HHVM/PHP environments

6.8k871.7M66](/packages/sebastian-environment)[symfony/dotenv

Registers environment variables from a .env file

3.8k226.7M2.3k](/packages/symfony-dotenv)[jenssegers/agent

Desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

4.8k67.8M440](/packages/jenssegers-agent)[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[behat/mink

Browser controller/emulator abstraction for PHP

1.6k86.1M606](/packages/behat-mink)

PHPackages © 2026

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