Skip to content

Shell

Nativella\Shell hands URLs and files over to the system's applications.

$shell->openUrl('https://github.com/lyrixx/nativella/issues');
$shell->openPath('/home/me/Documents/report.pdf');
$shell->showInFolder('/home/me/Documents/report.pdf');
$shell->trash('/home/me/Documents/old-report.pdf');
Method
openUrl(string $url): void Opens a URL in the default browser, or the mail client for mailto:.
openPath(string $path): void Opens a file or a directory with its default application.
showInFolder(string $path): void Opens the file manager on the directory of $path, with $path selected.
trash(string $path): void Moves a file or a directory to the trash, where the user can restore it. Desktop only.

A plain link to another website already opens in the system browser, not in the window. See Pages and JavaScript. openUrl() is for the other cases, when PHP decides what to open:

use Nativella\Event\MenuItemClicked;

if ($event instanceof MenuItemClicked && 'help.docs' === $event->id) {
    $shell->openUrl('https://github.com/lyrixx/nativella/tree/main/docs');
}

openUrl() opens whatever it is given, so only hand it URLs you trust, or that the user typed.