Using System_Launcher

Using System_Launcher – Launch files with associated applications.

Contributors

  • Olle Jonsson
  • Christian Weiske

Description

By using the operating system's features for opening a file or URL, this package simplifies writing command-line tools that open HTML documentation et cetera. For instance, upon successful install, the "Getting started" URL could be loaded in the browser.

Using System_Launcher

Open a local HTML file in the web browser

<?php
require_once 'System/Launcher.php';
$launcher = new System_Launcher;
$launcher->launch(dirname(__FILE__) . '/test.htm'true);
?>

At first, you need to instantitiate a new System_Launcher object. The operating system is determined there, which is needed for choosing a way of launching programs.

The launch() method tells the operating system to open the given file as it is associated. Browsers regularly open HTML documents, and image viewers open PNGs, and so on.

You can also feed it a URL instead of a file.