PHP code example of skyzyx / alfred-workflow-builder

1. Go to this page and download the library: Download skyzyx/alfred-workflow-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

skyzyx / alfred-workflow-builder example snippets


		

use Alfred\Workflow;

// Pass a Bundle ID
$w = new Workflow('com.ryanparman.my-workflow');
#=> <Alfred\Workflow>

$w->result(array(
    'uid'          => 'itemuid',
    'arg'          => 'itemarg',
    'title'        => 'Some Item Title',
    'subtitle'     => 'Some item subtitle',
    'icon'         => 'icon.png',
    'valid'        => 'yes',
    'autocomplete' => 'autocomplete'
));
echo $w->toXML();

$results = array();
$temp = array(
    'uid'          => 'itemuid',
    'arg'          => 'itemarg',
    'title'        => 'Some Item Title',
    'subtitle'     => 'Some item subtitle',
    'icon'         => 'icon.png',
    'valid'        => 'yes',
    'autocomplete' => 'autocomplete'
);
array_push($results, $temp);
echo $w->toXML($results);

$results = $w->mdfind('"kMDItemContentType == com.apple.mail.emlx"');
/* or */
$results = $w->mdfind('Alfred 2.app');
#=> (array) ['/Applications/Alfred 2.app']

$w->result(array (
    'uid'          => 'alfred',
    'arg'          => 'alfredapp',
    'title'        => 'Alfred',
    'subtitle'     => '/Applications/Alfred.app',
    'icon'         => 'fileicon:/Applications/Alfred.app',
    'valid'        => 'yes',
    'autocomplete' => 'Alfredapp',
));
echo $w->toXML();

use Alfred\Storage\Plist;

// Pass a Bundle ID and Plist name
$plist = new Plist('com.ryanparman.my-workflow', 'info');
#=> <Alfred\Storage\Plist>

$plist->setValue('username', 'rparman');

$plist->setValues(array(
    'username' => 'rparman',
    'password' => 'abc123',
    'zipcode'  => '90210',
));

$username = $plist->getValue('username');
#=> (string) rparman
bash
	php composer.phar install --optimize-autoloader