{"id":17689060,"url":"https://github.com/godbout/alfred-workflow-scriptfilter","last_synced_at":"2025-06-22T18:35:59.961Z","repository":{"id":38108194,"uuid":"168175795","full_name":"godbout/alfred-workflow-scriptfilter","owner":"godbout","description":"Generate Alfred 3 or 4 Workflow Results in PHP with a laugh.","archived":false,"fork":false,"pushed_at":"2023-04-19T19:44:53.000Z","size":229,"stargazers_count":17,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T02:27:31.660Z","etag":null,"topics":["alfred","alfred-workflow","php","results","scriptfilter","workflow"],"latest_commit_sha":null,"homepage":"https://sleeplessmind.com.mo/news/alfred-workflow-php-build-your-workflows-using-php/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/godbout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"godbout","ko_fi":"godbout"}},"created_at":"2019-01-29T15:14:53.000Z","updated_at":"2023-07-15T13:49:22.000Z","dependencies_parsed_at":"2024-10-24T14:26:52.731Z","dependency_job_id":"667d654a-02de-414f-a647-3f49ef8149c0","html_url":"https://github.com/godbout/alfred-workflow-scriptfilter","commit_stats":{"total_commits":93,"total_committers":2,"mean_commits":46.5,"dds":"0.021505376344086002","last_synced_commit":"b50f72ffa0a0e3490fca72776149003517502a1c"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/godbout/alfred-workflow-scriptfilter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godbout%2Falfred-workflow-scriptfilter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godbout%2Falfred-workflow-scriptfilter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godbout%2Falfred-workflow-scriptfilter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godbout%2Falfred-workflow-scriptfilter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/godbout","download_url":"https://codeload.github.com/godbout/alfred-workflow-scriptfilter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godbout%2Falfred-workflow-scriptfilter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261344556,"owners_count":23144887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alfred","alfred-workflow","php","results","scriptfilter","workflow"],"created_at":"2024-10-24T11:46:23.892Z","updated_at":"2025-06-22T18:35:54.937Z","avatar_url":"https://github.com/godbout.png","language":"PHP","funding_links":["https://github.com/sponsors/godbout","https://ko-fi.com/godbout"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePHP Alfred Workflow ScriptFilter\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/godbout/alfred-workflow-scriptfilter\"\u003e\u003cimg src=\"https://poser.pugx.org/godbout/alfred-workflow-scriptfilter/v/stable\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/godbout/alfred-workflow-scriptfilter/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/workflow/status/godbout/alfred-workflow-scriptfilter/tests\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/godbout/alfred-workflow-scriptfilter\"\u003e\u003cimg src=\"https://img.shields.io/scrutinizer/g/godbout/alfred-workflow-scriptfilter.svg\" alt=\"Quality Score\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/godbout/alfred-workflow-scriptfilter\"\u003e\u003cimg src=\"https://scrutinizer-ci.com/g/godbout/alfred-workflow-scriptfilter/badges/coverage.png?b=master\" alt=\"Code Coverage\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/godbout/alfred-workflow-scriptfilter\"\u003e\u003cimg src=\"https://poser.pugx.org/godbout/alfred-workflow-scriptfilter/downloads\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n___\n\n## Why\n\nStarting with Alfred 3.4.1 you can define [variables][1] for individual items and\nvariables and icon for each various modifiers (ctrl, cmd, shift, fn, alt) of each item.\nThat makes rendering the results for Alfred a little tougher than usual with the current tools\navailable, hence this package.\n\nIf you don't need the new fields introduced by Alfred 3.4.1 and 3.5, you might want to use\nJoe Tannenbaum's [package][2]. His API might be a little less heavier than mine.\n\n## Installation\n\n```php\ncomposer require godbout/alfred-workflow-scriptfilter\n``` \n## Usage\n\nThe main `ScriptFilter` class is a singleton. You can create many\ninstances of all the other classes: `Item`, `Variable`, `Icon`, and the `Mod` classes: `Ctrl`, `Fnn`, `Shift`, `Alt`, and `Cmd`.\n\nYou may check the structure and options of the Alfred Script Filter JSON Format here: https://www.alfredapp.com/help/workflows/inputs/script-filter/json/\n\n```php\nrequire __DIR__ . '/../vendor/autoload.php';\n\nuse Godbout\\Alfred\\Workflow\\ScriptFilter;\n\necho ScriptFilter::output();\n```\n\nwill result in:\n\n```json\n{\"items\":[]}\n```\n\nYou can add items, variables, rerun automatically your script:\n\n```php\nScriptFilter::add(\n    Item::create()\n        -\u003euid('uidd')\n        -\u003etitle('titlee')\n        -\u003esubtitle('subtitlee')\n        -\u003earg('argg')\n        -\u003eicon(\n            Icon::create('icon path')\n        )\n        -\u003evalid()\n        -\u003ematch('matchh')\n        -\u003eautocomplete('autocompletee')\n        -\u003emod(\n            Ctrl::create()\n                -\u003earg('ctrl arg')\n                -\u003esubtitle('ctrl subtitle')\n                -\u003evalid()\n        )\n        -\u003ecopy('copyy')\n        -\u003elargetype('largetypee')\n        -\u003equicklookurl('quicklookurll')\n);\n\nScriptFilter::add(\n    Variable::create('food', 'chocolate'),\n    Variable::create('dessert', 'red beans')\n);\n\nScriptFilter::rerun(4.5);\n\n$anotherItem = Item::create()\n    -\u003eicon(\n        Icon::createFileicon('icon pathh')\n    )\n    -\u003emods(\n        Shift::create()\n            -\u003esubtitle('shift subtitle'),\n        Fnn::create()\n            -\u003earg('fn arg')\n            -\u003evalid(true)\n    );\n\n$thirdItem = Item::create()\n    -\u003evariables(\n        Variable::create('guitar', 'fender'),\n        Variable::create('amplifier', 'orange')\n    )\n    -\u003emod(\n        Alt::create()\n            -\u003eicon(\n                Icon::createFileicon('alt icon path')\n            )\n            -\u003evariables(\n                Variable::create('grade', 'colonel'),\n                Variable::create('drug', 'power')\n            )\n    );\n\nScriptFilter::add($anotherItem, $thirdItem);\n\necho ScriptFilter::output();\n```\n\nwill result in:\n\n```json\n{\n    \"rerun\":4.5,\n    \"variables\":{\n        \"food\":\"chocolate\",\n        \"dessert\":\"red beans\"\n    },\n    \"items\":[\n        {\n            \"uid\":\"uidd\",\n            \"title\":\"titlee\",\n            \"subtitle\":\"subtitlee\",\n            \"arg\":\"argg\",\n            \"icon\":{\n                \"path\":\"icon path\"\n            },\n            \"valid\":true,\n            \"match\":\"matchh\",\n            \"autocomplete\":\"autocompletee\",\n            \"mods\":{\n                \"ctrl\":{\n                    \"arg\":\"ctrl arg\",\n                    \"subtitle\":\"ctrl subtitle\",\n                    \"valid\":true\n                }\n            },\n            \"text\":{\n                \"copy\":\"copyy\",\n                \"largetype\":\"largetypee\"\n            },\n            \"quicklookurl\":\"quicklookurll\"\n        },\n        {\n            \"icon\":{\n                \"path\":\"icon pathh\",\n                \"type\":\"fileicon\"\n            },\n            \"mods\":{\n                \"shift\":{\n                    \"subtitle\":\"shift subtitle\"\n                },\n                \"fn\":{\n                    \"arg\":\"fn arg\",\n                    \"valid\":true\n                }\n            }\n        },\n        {\n            \"mods\":{\n                \"alt\":{\n                    \"icon\":{\n                        \"path\":\"alt icon path\",\n                        \"type\":\"fileicon\"\n                    },\n                    \"variables\":{\n                        \"grade\":\"colonel\",\n                        \"drug\":\"power\"\n                    }\n                }\n            },\n            \"variables\":{\n                \"guitar\":\"fender\",\n                \"amplifier\":\"orange\"\n            }\n        }\n    ]\n}\n```\n\nYou can sort your results ascendingly, descendingly, by title or anything else:\n\n```php\n\n/**\n * Will sort the items ascendingly\n * based on titles.\n */\nScriptFilter::add(...);\nScriptFilter::sortItems();\nScriptFilter::output();\n\n/**\n * Will sort the items descendingly\n * based on subtitles.\n */\nScriptFilter::add(...);\nScriptFilter::sortItems('desc', 'subtitle');\nScriptFilter::output();\n```\n\nYou can filter your results (you might want to do this with the input from the user) based on any field from your items:\n\n```php\n\n/**\n * Only items with a title that contains\n * 'start' will show up in the output.\n */\nScriptFilter::add(...);\nScriptFilter::filterItems('start');\nScriptFilter::output();\n\n/**\n * Only items with a subtitle that contains\n * 'end' will show up in the output.\n */\nScriptFilter::add(...);\nScriptFilter::filterItems('end', 'subtitle');\nScriptFilter::output();\n```\n\n## Helpers\n\nThere's a couple of helpers that should make your code a bit more enjoyable to write. (Or not.)\n\n### ScriptFilter\n\nThe ScriptFilter can be written using a fluent interface:\n\n```php\nScriptFilter::create()\n    -\u003eitem($item)\n    -\u003evariable(Variable::create('gender', 'undefined'))\n    -\u003eitems($anotherItem, $oneMoreItem)\n    -\u003evariables($aVariable, $anotherVariable)\n    -\u003ererun(4)\n    -\u003eitem(Item::create());\n```\n\n### Item\n\n```php\nItem::createDefault();\n// same same\nItem::create()-\u003edefault();\n// same same\nItem::create()-\u003etype('default');\n\n\nItem::createFile();\n// same same\nItem::create()-\u003efile();\n// same same\nItem::create()-\u003etype('file');\n\n\nItem::createSkipcheck();\n// same same\nItem::create()-\u003eskipcheck();\n// same same\nItem::create()-\u003etype('file:skipcheck');\n\n\nItem::create()-\u003ecopy('text to copy');\n// same same\nItem::create()-\u003etext('copy', 'text to copy');\n\n\nItem::create()-\u003elargetype('show large');\n// same same\nItem::create()-\u003etext('largetype', 'show large');\n```\n\n### Icon\n\n```php\nIcon::create('~/Desktop');\n// same same\nIcon::create()-\u003epath('~/Desktop');\n\n\nIcon::createFileicon('~/Desktop');\n// same same\nIcon::create('~/Desktop')-\u003efileicon();\n\n\nIcon::createFiletype('~/Desktop');\n// same same\nIcon::create()-\u003epath('~/Desktop')-\u003efiletype();\n```\n\n### Variable\n\n```php\nVariable::create('guitar', 'fender');\n// same same\nVariable::create()-\u003ename('guitar')-\u003evalue('fender');\n\n\n/**\n * Anywhere you use the -\u003evariable(...) fluent interface\n * you can pass the name and value arguments directly\n * if this is your thing.\n */\n...-\u003evariable(Variable::create('gender', 'unknown'));\n// same same\n...-\u003evariable('gender', 'unknown');\n```\n\n## Full API\n\nYou might want to check the tests to see the full API: [tests][3]\n\nThe API should mostly help you avoid typing too much and putting wrong data\nwhere Alfred is expecting something strict.\n\n## Alternatives\n\n* [alfred-workflow][2] by Joe Tannenbaum\n\n\n[1]: https://www.alfredapp.com/help/workflows/inputs/script-filter/json/#variables\n[2]: https://github.com/joetannenbaum/alfred-workflow\n[3]: https://github.com/godbout/alfred-workflow-scriptfilter/tree/master/tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodbout%2Falfred-workflow-scriptfilter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgodbout%2Falfred-workflow-scriptfilter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodbout%2Falfred-workflow-scriptfilter/lists"}