Quickstart PHP

PHP

1. Download the bundlet, and place it in your workflow's root directory.

2. Include the bundlet

require_once('alfred.bundler.php');

3. Instantiate a Bundler object.

$b = new AlfredBundler;

Read the implementation page for more advanced ways to initialize the bundler.

Using the Bundler

Load a Library
Load a Utility
Load an Icon
Load a Composer Package
Load a Wrapper
Send a Notification
The icon argument falls back to the workflow icon if it is available.
Logging

For general information on logging with the Bundler, read the log page.

In order to use the logs, you need to initialize the bundler differently:

The wf_log key will give you access to console logs as well as a default file log located in the workflow’s data directory named {workflow-bundle-id}.log. So, if your workflow’s bundle id is com.spr.bundler.example. The log will be located at ~/Library/Application Support/Alfred 2/Workflow Data/com.spr.bundler.example/com.spr.bundler.example.log.

After that, to log a message, you can use

That will log the message at level “info” in both the console and the file log.

The third argument can be either console, file, or both. The valid log levels are debug, info, warning, error, critical. If you input an invalid log level, then an error will be logged to the console, and the log level will fallback to info.

There are shortcut functions available too...

Log a message to the console:
The following take two arguments (message, destination), although the second is optional. If you do not specify a log destination, it will fallback to console.
Log a debug message
Log an info message to a file
Log a warning to the console:
Log an error
Log a critical error to the console and the file log
Note: Logging an error or a critical error will not affect the running of your workflow. If you want to raise an error, then you must code that in manually. The log level describes the level but nothing more.
Questions?

Post on the Alfred Forum thread.

Bug Reports?

Open an issue in the Github queue.