PHPackages                             godbout/alfred-workflow-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. godbout/alfred-workflow-php

Abandoned → [godbout/alfred-workflow-scriptfilter](/?search=godbout%2Falfred-workflow-scriptfilter)Library[Utility &amp; Helpers](/categories/utility)

godbout/alfred-workflow-php
===========================

Generate Alfred 3 or 4 Workflow Results in PHP with a laugh.

2.3.0(5y ago)1758[2 PRs](https://github.com/godbout/alfred-workflow-php/pulls)MITPHPPHP ^7.3 || ^8.0

Since Feb 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/godbout/alfred-workflow-php)[ Packagist](https://packagist.org/packages/godbout/alfred-workflow-php)[ Docs](https://github.com/godbout/alfred-workflow-scriptfilter)[ RSS](/packages/godbout-alfred-workflow-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (18)Used By (0)

PHP Alfred Workflow ScriptFilter
================================

[](#php-alfred-workflow-scriptfilter)

 [![Latest Stable Version](https://camo.githubusercontent.com/380cf5cf14acfddc5333bf3a2e326f770e0d32dff861ae4dc36c6af5ec01085c/68747470733a2f2f706f7365722e707567782e6f72672f676f64626f75742f616c667265642d776f726b666c6f772d73637269707466696c7465722f762f737461626c65)](https://packagist.org/packages/godbout/alfred-workflow-scriptfilter) [![Build Status](https://camo.githubusercontent.com/d557b8986861a5eb31fa653b63a2d103996a8843d9eb8198f88b0e88da21dfdf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f676f64626f75742f616c667265642d776f726b666c6f772d73637269707466696c7465722f7465737473)](https://github.com/godbout/alfred-workflow-scriptfilter/actions) [![Quality Score](https://camo.githubusercontent.com/df670997ce4c4e4f0af41325fc687e69d3b05a89d8e61c6c3b82cd31ec55d330/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f676f64626f75742f616c667265642d776f726b666c6f772d73637269707466696c7465722e737667)](https://scrutinizer-ci.com/g/godbout/alfred-workflow-scriptfilter) [![Code Coverage](https://camo.githubusercontent.com/5b788c90bd606fce2f82b8326bd15b4cef32cff390ec32069147357eafad920e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676f64626f75742f616c667265642d776f726b666c6f772d73637269707466696c7465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/godbout/alfred-workflow-scriptfilter) [![Total Downloads](https://camo.githubusercontent.com/94558695a157ffe7321e4a531fb3f598d2284e41fe3d5f209a8759d786ce2a32/68747470733a2f2f706f7365722e707567782e6f72672f676f64626f75742f616c667265642d776f726b666c6f772d73637269707466696c7465722f646f776e6c6f616473)](https://packagist.org/packages/godbout/alfred-workflow-scriptfilter)

---

Why
---

[](#why)

Starting with Alfred 3.4.1 you can define [variables](https://www.alfredapp.com/help/workflows/inputs/script-filter/json/#variables) for individual items and variables and icon for each various modifiers (ctrl, cmd, shift, fn, alt) of each item. That makes rendering the results for Alfred a little tougher than usual with the current tools available, hence this package.

If you don't need the new fields introduced by Alfred 3.4.1 and 3.5, you might want to use Joe Tannenbaum's [package](https://github.com/joetannenbaum/alfred-workflow). His API might be a little less heavier than mine.

Installation
------------

[](#installation)

```
composer require godbout/alfred-workflow-scriptfilter
```

Usage
-----

[](#usage)

The main `ScriptFilter` class is a singleton. You can create many instances of all the other classes: `Item`, `Variable`, `Icon`, and the `Mod` classes: `Ctrl`, `Fnn`, `Shift`, `Alt`, and `Cmd`.

You may check the structure and options of the Alfred Script Filter JSON Format here:

```
require __DIR__ . '/../vendor/autoload.php';

use Godbout\Alfred\Workflow\ScriptFilter;

echo ScriptFilter::output();
```

will result in:

```
{"items":[]}
```

You can add items, variables, rerun automatically your script:

```
ScriptFilter::add(
    Item::create()
        ->uid('uidd')
        ->title('titlee')
        ->subtitle('subtitlee')
        ->arg('argg')
        ->icon(
            Icon::create('icon path')
        )
        ->valid()
        ->match('matchh')
        ->autocomplete('autocompletee')
        ->mod(
            Ctrl::create()
                ->arg('ctrl arg')
                ->subtitle('ctrl subtitle')
                ->valid()
        )
        ->copy('copyy')
        ->largetype('largetypee')
        ->quicklookurl('quicklookurll')
);

ScriptFilter::add(
    Variable::create('food', 'chocolate'),
    Variable::create('dessert', 'red beans')
);

ScriptFilter::rerun(4.5);

$anotherItem = Item::create()
    ->icon(
        Icon::createFileicon('icon pathh')
    )
    ->mods(
        Shift::create()
            ->subtitle('shift subtitle'),
        Fnn::create()
            ->arg('fn arg')
            ->valid(true)
    );

$thirdItem = Item::create()
    ->variables(
        Variable::create('guitar', 'fender'),
        Variable::create('amplifier', 'orange')
    )
    ->mod(
        Alt::create()
            ->icon(
                Icon::createFileicon('alt icon path')
            )
            ->variables(
                Variable::create('grade', 'colonel'),
                Variable::create('drug', 'power')
            )
    );

ScriptFilter::add($anotherItem, $thirdItem);

echo ScriptFilter::output();
```

will result in:

```
{
    "rerun":4.5,
    "variables":{
        "food":"chocolate",
        "dessert":"red beans"
    },
    "items":[
        {
            "uid":"uidd",
            "title":"titlee",
            "subtitle":"subtitlee",
            "arg":"argg",
            "icon":{
                "path":"icon path"
            },
            "valid":true,
            "match":"matchh",
            "autocomplete":"autocompletee",
            "mods":{
                "ctrl":{
                    "arg":"ctrl arg",
                    "subtitle":"ctrl subtitle",
                    "valid":true
                }
            },
            "text":{
                "copy":"copyy",
                "largetype":"largetypee"
            },
            "quicklookurl":"quicklookurll"
        },
        {
            "icon":{
                "path":"icon pathh",
                "type":"fileicon"
            },
            "mods":{
                "shift":{
                    "subtitle":"shift subtitle"
                },
                "fn":{
                    "arg":"fn arg",
                    "valid":true
                }
            }
        },
        {
            "mods":{
                "alt":{
                    "icon":{
                        "path":"alt icon path",
                        "type":"fileicon"
                    },
                    "variables":{
                        "grade":"colonel",
                        "drug":"power"
                    }
                }
            },
            "variables":{
                "guitar":"fender",
                "amplifier":"orange"
            }
        }
    ]
}
```

You can sort your results ascendingly, descendingly, by title or anything else:

```
/**
 * Will sort the items ascendingly
 * based on titles.
 */
ScriptFilter::add(...);
ScriptFilter::sortItems();
ScriptFilter::output();

/**
 * Will sort the items descendingly
 * based on subtitles.
 */
ScriptFilter::add(...);
ScriptFilter::sortItems('desc', 'subtitle');
ScriptFilter::output();
```

You can filter your results (you might want to do this with the input from the user) based on any field from your items:

```
/**
 * Only items with a title that contains
 * 'start' will show up in the output.
 */
ScriptFilter::add(...);
ScriptFilter::filterItems('start');
ScriptFilter::output();

/**
 * Only items with a subtitle that contains
 * 'end' will show up in the output.
 */
ScriptFilter::add(...);
ScriptFilter::filterItems('end', 'subtitle');
ScriptFilter::output();
```

Helpers
-------

[](#helpers)

There's a couple of helpers that should make your code a bit more enjoyable to write. (Or not.)

### ScriptFilter

[](#scriptfilter)

The ScriptFilter can be written using a fluent interface:

```
ScriptFilter::create()
    ->item($item)
    ->variable(Variable::create('gender', 'undefined'))
    ->items($anotherItem, $oneMoreItem)
    ->variables($aVariable, $anotherVariable)
    ->rerun(4)
    ->item(Item::create());
```

### Item

[](#item)

```
Item::createDefault();
// same same
Item::create()->default();
// same same
Item::create()->type('default');

Item::createFile();
// same same
Item::create()->file();
// same same
Item::create()->type('file');

Item::createSkipcheck();
// same same
Item::create()->skipcheck();
// same same
Item::create()->type('file:skipcheck');

Item::create()->copy('text to copy');
// same same
Item::create()->text('copy', 'text to copy');

Item::create()->largetype('show large');
// same same
Item::create()->text('largetype', 'show large');
```

### Icon

[](#icon)

```
Icon::create('~/Desktop');
// same same
Icon::create()->path('~/Desktop');

Icon::createFileicon('~/Desktop');
// same same
Icon::create('~/Desktop')->fileicon();

Icon::createFiletype('~/Desktop');
// same same
Icon::create()->path('~/Desktop')->filetype();
```

### Variable

[](#variable)

```
Variable::create('guitar', 'fender');
// same same
Variable::create()->name('guitar')->value('fender');

/**
 * Anywhere you use the ->variable(...) fluent interface
 * you can pass the name and value arguments directly
 * if this is your thing.
 */
...->variable(Variable::create('gender', 'unknown'));
// same same
...->variable('gender', 'unknown');
```

Full API
--------

[](#full-api)

You might want to check the tests to see the full API: [tests](https://github.com/godbout/alfred-workflow-scriptfilter/tree/master/tests)

The API should mostly help you avoid typing too much and putting wrong data where Alfred is expecting something strict.

Alternatives
------------

[](#alternatives)

- [alfred-workflow](https://github.com/joetannenbaum/alfred-workflow) by Joe Tannenbaum

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 97.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Recently: every ~55 days

Total

16

Last Release

1934d ago

Major Versions

0.2.0 → 1.0.02019-02-25

1.5.1 → 2.0.02020-05-30

PHP version history (5 changes)0.1.0PHP ^7.1

1.1.0PHP ^7.0

2.1.0PHP ^7.2

2.2.0PHP ^7.4 || ^8.0

2.3.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a99985b9d95710208c2b66a8935acaf3ef0e09d98d8732408a683a26c09351d?d=identicon)[godbout](/maintainers/godbout)

---

Top Contributors

[![godbout](https://avatars.githubusercontent.com/u/121373?v=4)](https://github.com/godbout "godbout (94 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

alfredalfred-workflowphpresultsscriptfilterworkflowphpworkflowresultsalfredalfred-workflowscriptfilter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/godbout-alfred-workflow-php/health.svg)

```
[![Health](https://phpackages.com/badges/godbout-alfred-workflow-php/health.svg)](https://phpackages.com/packages/godbout-alfred-workflow-php)
```

###  Alternatives

[godbout/alfred-workflow-scriptfilter

Generate Alfred 3 or 4 Workflow Results in PHP with a laugh.

173.7k1](/packages/godbout-alfred-workflow-scriptfilter)[fab2s/nodalflow

A PHP Nodal WorkFlow

16362.4k1](/packages/fab2s-nodalflow)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
