PHP formatter for BitBar plugins
Clone or download
Steve Edson
Steve Edson test against php 7.2
Latest commit f4b4dcf Jun 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/SteveEdson more fixes to support php 5.3 Jun 19, 2018
tests adding tests Jun 19, 2018
.gitignore added gitignore Jan 22, 2016
.travis.yml test against php 7.2 Jun 19, 2018
LICENSE.md Rename LICENCE.md to LICENSE.md Feb 3, 2016
composer.json only support PHP 5.6 onwards, see https://secure.php.net/supported-ve… Jun 19, 2018
phpunit.xml fixed tests Jun 19, 2018
readme.md fixed markdown syntax for #12 Jun 18, 2018

readme.md

BitBar PHP Formatter

Latest Stable Version Total Downloads Latest Unstable Version License

Installing

Currently, BitBar reads any file in your directory a plugin, and tries to execute it. To workaround this, create a hidden folder, beginning with a dot, for example .bitbar/. In this directory create or edit your composer.json to include the library:

{
  "require": {
    "steveedson/bitbar-php": "dev-master"
  }
}

or run $ composer require "steveedson/bitbar-php"

File Structure

You file structure inside your plugins directory, should look something like:

.
├── .bitbar/
│   ├── composer.json
│   └── vendor/
└── test.5m.php

Usage

In your BitBar plugins directory, create a file, e.g. test.5m.php. Don't forget to add the shebang at the beginning.

#!/usr/bin/php

<?php

require ".bitbar/vendor/autoload.php";

use SteveEdson\BitBar;

// Create BitBar formatter
$bb = new BitBar();

// Create the first line
$line = $bb->newLine();

// Set the text and formatting
$line
    ->setText("Hello World")
    ->setColour("yellow")
    ->setUrl("https://steveedson.co.uk")
    ->show();

Examples

Using Sub Menus

// Create BitBar formatter
$bb = new BitBar();

// Create the first line
$line = $bb->newLine();

// Set the text and formatting
$mainMenu = $line
    ->setText("Servers")
    ->setColour("yellow");

$mainMenu = $mainMenu->addSubMenu()
    ->newLine()
    ->setText("Server 1")
    ->setUrl('http://server1.com');

$mainMenu = $mainMenu->addSubMenu()
    ->newLine()
    ->setText("Server 2")
    ->setUrl('http://server2.com');

$mainMenu->show();