Releases: nubs/sensible
Version 0.5.0: International Puppy Studio
Version 0.4.0: The Glory of Zombie Omega
Backwards Compatibility Breakers
This update majorly changes the standard API of this library. The factory classes are the primary entrypoint now and the old classes just house behavior to use the commands. PHP 5.4 is now a requirement, as is the usage of nubs/which for locating commands in the user's PATH. The result of all this is something much more extensible (eventually for adding Windows Support) and something that has fully configurable behaviors.
Version 0.3.0: Telekinetic Hovercraft For Kids
Major Features
Locating Commands
The paths are no longer strictly absolute paths. nubs/which can be used in order to locate the commands by basename from the user's PATH. See issue #4.
Pager
A new \Nubs\Sensible\Pager class provides access to the user's preferred pager (like more, less, etc.).
Browser
A new \Nubs\Sensible\Browser class provides access to the user's preferred browser (like firefox, chrome, etc.).
Minor Features
- The default editor can be a list of editors to choose from based on
availability.
Developer Changes
- Contribution guidelines have been added.
- The codesniffer is now run against tests.
- A build script has been added to make it easy to run phpcs/phpunit.
Version 0.2.0: Mysterious Bobsled For Kids
Major Features
Editing Files
A new editFile method was added to the Editor class. This method makes it slightly easier to instantiate an editor using Symfony's Process component. The process is created and run synchronously and the Process element is returned. For example:
use Nubs\Sensible\Editor;
use Symfony\Component\Process\ProcessBuilder;
$editor = new Editor();
$process = $editor->editFile(new ProcessBuilder(), '/path/to/a/file');
if ($process->isSuccessful()) {
// Process changes to file?
} else {
// Editor exited with a non-zero status - user canceled editing?
}Editing Data
As a wrapper to editFile, a new editData method was also added that handles editing a string using a temporary file (located in sys_get_temp_dir()) as an intermediary. The modified string will be returned. If the editor exits with a non-zero status, the modifications are discarded and the original string is returned unchanged.
` element is returned. For example:
use Nubs\Sensible\Editor;
use Symfony\Component\Process\ProcessBuilder;
$editor = new Editor();
$data = $editor->editData(new ProcessBuilder(), 'The text to edit here');
// Continue using the modified $dataVersion 0.1.0: Kirby's Scooter Universe
This is the initial release of sensible, a PHP library for finding sensible user programs, like editor, pager, and browser. Currently there is only a class for getting the default editor.
Major Features
Sensible Editor
The \Nubs\Sensible\Editor class makes it easy to get the path to the user's preferred editor. If available, the sensible-editor command (from debian) is used. Otherwise the EDITOR environment variable is consulted. If that still fails to find an editor, then a default editor, /bin/ed is used.
$sensibleEditor = new \Nubs\Sensible\Editor();
$editor = $sensibleEditor->get();The class takes seveal options on initialization:
$sensibleEditor = new \Nubs\Sensible\Editor(
[
'sensibleEditorPath' => '/path/to/sensible-editor', // defaults to /usr/bin/sensible-editor
'defaultEditorPath' => '/path/to/default/editor', // defaults to /bin/ed
'environment' => \Habitat\Habitat::getInstance()->getEnvironment(), // defaults to null (use built-in getenv)
]
);