Download the PHP package nubs/sensible without Composer
On this page you can find all versions of the php package nubs/sensible. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nubs/sensible
More information about nubs/sensible
Files in nubs/sensible
Informations about the package sensible
sensible
A PHP library for finding sensible user programs, like editor, pager, and browser.
Requirements
This library requires PHP 5.6, or newer.
Installation
This package uses composer so you can just add
nubs/sensible
as a dependency to your composer.json
file or execute the
following command:
Supported Program Types
This library supports opening a text editor (like vim), a pager (like more), and a browser (like firefox).
Program Factories
The recommended way to initialize one of the supported program loaders is to use the included factories.
Browser Factory
The browser factory uses a command locator (via 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:
If you want to override the default list of browsers:
Editor Factory
The editor factory uses your EDITOR
environment variable if set, otherwise it
uses a command locator (via 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:
If you want to override the default list of editors:
Pager Factory
The pager factory uses your PAGER
environment variable if set, otherwise it
uses a command locator (via 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:
If you want to override the default list of pagers:
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
A browser can be executed to load a supported URI. For example:
Editor
The editor can be used to edit files. For example:
There is also a convenient shorthand for editing a string in an editor by means of a temporary file. For example:
This will return the input unaltered if the process does not exit successfully.
Pager
The pager passes the file or string to the configured pager for convenient viewing. For example, for a file source:
Or for a string source:
CLI Interface
There is also a CLI interface for Linux systems that imitates Ubuntu's
sensible-*
commands. It is available as nubs/sensible-cli
.
License
sensible is licensed under the MIT license. See LICENSE for the full license text.