Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Alfred 3
  • Make the Most of Alfred
    • Discussion & Help
    • Bug Reports
    • Alfred Feature Suggestions
    • Themes
  • Alfred Workflows
    • Share your Workflows
    • Workflow Help & Questions
    • Advanced Tips & Tricks
  • Alfred Themes
  • Alfred Remote for iOS
    • Alfred Remote Discussion & Help
    • Remote Connection Troubleshooting
  • Alfred 5 Early Access
    • Alfred 5 Early Access


  • Articles
    • Forum Integration
    • Frontpage
  • Pages
  • Miscellaneous
    • Databases
    • Templates
    • Media

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start




Website URL




  1. Hello again. I'm rebuilding my own Alfred-Time Workflow (use Toggl and/or Harvest with Alfred) and I started developing some PHP packages to ease the development of Alfred Workflows in PHP. Last week I've released Alfred Workflow ScriptFilter that allows you to create a ScriptFilter output. This week I've worked on handling configuration settings. I think it's quite nice when we developed a Workflow not to bother spending time on things that are common to a lot of them. So if you use PHP and need to store some config, you might want to have a look at the package I've made. Here's the GitHub link: https://github.com/godbout/alfred-workflow-config Currently it's tailored for my needs. For example there's no feature to delete a config file. If you need stuff like that, you can open an issue on GitHub or we can talk about it here. I'll see how I can extend usefully. Happy productivity!
  2. if you manage your servers and/or sites with the fantastic Ploi service, here's now a Workflow to handle stuff from Alfred: actually you can only refresh the PHP OPcache. and only on one server. this is the most ridiculous Workflow i've done so far. i love it. GitHub: https://github.com/godbout/alfred-ploi Packal: http://www.packal.org/workflow/alfred-ploi
  3. Hello there. To build cleaner workflows I needed to use some of the new fields found in Alfred 3.4.1 and 3.5. I usually use the fantastic package from Joe Tannenbaum to build my workflows but it's not updated and its fluent api is starting to show its limitation with the new nested fields. So I build my own. I started using it to build the v2 of my Alfred Time package and I'm quite pleased with it so I'm thinking, if you need to build workflows that handle the new nested field, you might want to have a look at my workflow. If not, Joe's package might have a nicer API. https://github.com/godbout/alfred-workflow-php Have fun, and be productive with Alfred!
  4. I worked with small PHP scripts to write my own workflows and noticed that I often would do the same jobs with every script again, so I decided to build a little toolkit around the Symfony 4.1 Command component. It provides a way to seamless have different states for Autocompletion and an easy way to configure variables that you can use in your script (saves it to .env file). As a proof-of-concept I wrote a movie-rating workflow in which you can rate your movie in different categories. The PHP-Code is as short as this command: class MovieRatingCommand extends AlfredInteractiveContainerAwareCommand { protected function configure() { $this ->setName('movie-rating') ->addArgument('category', InputArgument::OPTIONAL) ->addArgument('stars', InputArgument::OPTIONAL) ->addArgument('movie', InputArgument::OPTIONAL + InputArgument::IS_ARRAY); } protected function initialize(InputInterface $input, OutputInterface $output) { $stars = $this->getContainer()->getParameter('stars'); $categories = $this->getContainer()->getParameter('categories'); $filename = $this->getContainer()->getParameter('filename'); $sheetname = $this->getContainer()->getParameter('sheetname'); $tablename = $this->getContainer()->getParameter('tablename'); $this->addArgumentsAllowedValues('stars', $stars); $this->addArgumentsAllowedValues('category', $categories); $this->addInputHandler(['category', 'stars'], function () { $workflow = new WorkflowResult(); $workflow->setValid(false); $workflow->setTitle('Insert movie name to rate'); return [$workflow]; }); $showQuestions = function ($arguments) use ($categories, $filename, $sheetname, $tablename) { $movie = $arguments['movie']; $category = $arguments['category']; $stars = $arguments['stars']; if (!is_array($stars)) { $result = new WorkflowResult(); $result->setValid(true); $result->setTitle('Rate ' . $movie . ' - ' . $category . ': ' . $stars . ' stars'); $result->setSubtitle('Rate ' . $movie . ' in category "' . $category . '": ' . $stars . ' stars'); $result->setLargetype('Rate ' . $movie . ' in category "' . $category . '": ' . $stars . ' stars'); $result->setArg(json_encode([ 'movie' => $movie, 'currentdate' => (new \DateTime())->format('d.m.Y'), 'category' => $category, 'stars' => $stars, ])); $this->workflowHelper->variable('movie', $movie); $this->workflowHelper->variable('currentdate', (new \DateTime())->format('d.m.Y')); $this->workflowHelper->variable('category', iconv("ISO-8859-1", "UTF-8", utf8_decode($category))); $this->workflowHelper->variable('stars', $stars); $this->workflowHelper->variable('filename', $filename ?: null); $this->workflowHelper->variable('sheetname', $sheetname ?: null); $this->workflowHelper->variable('tablename', $tablename ?: null); return [$result]; } }; $this->addInputHandler(['category', 'stars', 'movie'], $showQuestions); } } You can find the Proof-of-concept here: https://github.com/dpeuscher/alfred-movie-rating. The Alfred-Symfony Toolkit can be found here: https://github.com/dpeuscher/alfred-symfony-tools. You can also use this composer command to use it: composer req dpeuscher/alfred-symfony-tools Thoughts, ideas, contributions are highly appreciated.
  5. Hi All Apologies if this has already been dealt with (I have searched and not found any conclusive answer on the forum). Is there a way to have curly bracket placeholders other than {query} - specifically {clipboard:0}, {clipboard:1}, {clipboard:2}, ... - evaluated within a php script? It appears that {clipboard:7} does not get evaluated upon initialisation like {query} does, but rather remains a placeholder right up to the moment where it is passed to some Alfred output such as Large Type, and only then is the clipboard value retrieved from the DB. Code example: $query = "{query}"; // $query has been assigned the value passed to the script $i = 7; $history_item = "{clipboard:$i}"; // $history_item has not been assigned any value from the clipboad stack - it holds the literal string value '{clipboard:7}' That means I can't access, search, and manipulate the clipboard history items within my code. Will I need to query clipboard.alfdb manually, or is there a simpler solution? All help appreciated
  6. Hey there Alfred Community, Full disclaimer: I am a hopeless newbie when it comes to the topics I'm addressing here, so I apologize in advance for ambiguous vocabulary. Basically, I am trying to use a combination of "File Filter" and "Run Script" to open a server on a specific folder (for development's sake). In Terminal, I would do the following: cd ~/PathToRelevantFolder php -S localhost: (Port) How do I transform this into a workflow such that I can use a file filter to return my folder of interest and provide an additional argument that allows me to specify the port I wish to use for the local host (e.g. 8000, 9090, 3012...). It's the latter half (providing the port argument) that's giving me the most difficulty. My thanks in advance for any help anyone can give me! -Colin
  7. With the help of answers here I managed to make a workflow that uses Terminal to call a PHP script to delete a file on a remote server, getting the file name from the most recent item in the clipboard. I don't actually need to see the Terminal after the script has completed, but I can't seem to find a way to just run it in the background, or quit Terminal when done. Any suggestions welcome. Thanks
  8. Couldn't think of a better title. Too many questions. WORKFLOW BACKGROUND As a webdeveloper you highly likely find yourself using classic background colors as you build complex layouts. The color won't stay for long, so it has to be typed fast. It doesn't make sense to add variables of a beautiful debugging color pallet.. so you write `background: red`, `background: yellow` – But these colors just look awful. CSS has many many other names you could remember.. (https://www.w3schools.com/colors/colors_names.asp) I can't – WORKFLOW PURPOSE "Alt+Space" > "csc" > Look > CMD+5 > "LightBlueSky" gets pasted right into active application. WHAT I HAVE SO FAR (php workflow with workflows.php) – I chose my favorite colors and put them in an associative Array – I (want to) shuffle the array so you don't forcefully fall in love with colors 1-3 – You can filter the colors by their name (Woop Woop!) – dynamicIcon.php that creates an square image as preview for the color – Activating an item pastes it to active app and doesn't polute the clipboard-history (Thanks, Alfred!) Obviously it doesn't go as smooth as I wish it to. So here are the two main issues I am facing: 1) dynamicIcon.php successfully creates an image, when accessed via a browser, but as a parameter in "$wf->result()" shows me the finger! 2) Shuffling the assoc-array works in a conventional webdev-environment, but again, Alfred shows me the finger on this one! Both issues probably no-brainers for advanced workflowers (:D) and veterans– I guess the icon-parameter needs a path (string) pointing to an actual image; so .. I need to save / cache the image created by dynamicIcon.php somewhere? Why-No-Shuffle is a complete mystery to me. Here is the beautiful lady: https://www.dropbox.com/s/sfm7kh1c6hh70oc/Colorfull Alpha.alfredworkflow?dl=0 Or if you want to see the code here: Scriptfilter: // // Load the PHP workflow library. include_once("workflows.php"); // // Create the workflow object to use. $wf = new Workflows(); // // Get the raw query and store it for use. $clean = trim("{query}"); // // Set the colors $colors = array( "DarkSlateBlue" => "483D8B", "RoyalBlue" => "4169E1", "RebeccaPurple" => "663399", "LightSkyBlue" => "87CEFA", "PaleGreen" => "98FB98", "Sienna" => "A52A2A", "GreenYellow" => "ADFF2F", "RosyBrown" => "8C8F8F", "DarkKhaki" => "BDB76B", "Silver" => "C0C0C0", "MediumVioletRed" => "C71585", "Chocolate" => "D2691E", "Peru" => "CD853F", "Orchid" => "DA70D6", "Plum" => "DDA0DD", "Gainsboro" => "DCDCDC", "Lavender" => "E6E6FA", "DarkSalmon" => "E9967A", "LightCoral" => "F08080" ); // // Shuffle assoc array function shuffle_assoc($my_array) { $keys = array_keys($my_array); shuffle($keys); foreach($keys as $key) { $new[$key] = $my_array[$key]; } $my_array = $new; return $my_array; } $shuffled_colors = shuffle_assoc($colors); // // Build items foreach ($shuffled_colors as $title => $hex) { $reg = '/(.*){query}(.*)/i'; if (!empty("{query}") && !preg_match($reg, $title)) continue; $wf->result($title, $title, $title, $hex, "dynamicIcon.php?hex=" . $hex, "yes"); } // // Alfred workflow.php magic producing the items, I guess? echo $wf->toxml(); dynamicIcon.php header("Content-type: image/png"); $hex = "#" . ltrim($_GET["hex"], "#"); // to make with or without hash valid parameter; list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x"); $im = @imagecreate(64,64) or die("cannot initialize new GD image stream"); $backgroundColor = imagecolorallocate($im, $r, $g, $b); imagepng($im); imagedestroy($im); Thanks! Louis PS: Name and keyword definitely not final;
  9. I have a workflow (download it here: https://cl.ly/3C0n0e1n3W2N) that works and allows me to select some text like "12345" and use a hotkey to launch a URL of https://example.com/issues/{query} -> https://example.com/issues/12345 However, I want to enhance it to be able to support selecting text like "12345,281928", do the hotkey, then open two browser tabs: {query} -> A = 12345 B = 281928 1: open https://example.com/issues/12345 2: also open https://example.com/issues/281928 last one? then we're all done. I know PHP well so I could do explode( ',' {query} ), but I'm not sure how to use {query} (is it usable in a PHP script?) and I'm not sure how to tell it to loop through all the items in the array. If Alfred can't use PHP to do this, that's fine, but I'm not well versed in bash, AppleScript, and the rest. Thanks for any help!
  10. I am in need of a script or scripting to parse an onslaught of email data in Gmail and organized in a google sheets file which the column headers are titled in conjunction with the need data from the emails. This is how the data is relayed to me which I need a script to extract the indicated fields below into a new cell within their respected columns in Google sheets. If anyone can help I would greatly appreciate it, sure make my day a lot easier. Thank you. It was much easier to just screenshot the key I created to map out what I really need and what everything looks like on my end. (See screenshots below) The pertinent email will be subject titled: Fwd: Debt Settlement. Screenshot Screenshot2 Again thank you to anyone who can help me with this.
  11. StackOverflow Search for Alfred Search for answers on StackOverflow.com from Alfred 2. Download Get StackOverflow for Alfred from GitHub or Packal. Usage .so <query> — Search StackOverflow.com for <query>. See below for syntax. ↩ or ⌘+NUM — Open result in default browser ⌘+L — Show full question title in Alfred's Large Text window Query syntax By default, words in <query> will be search for in the title of posts. To specify a tag, prefix it with ., e.g. python will search for python in the post title, .python will search for the tag python. Results Answered questions will be shown first in the list of results (and have a tick on their icon). Licensing, thanks This workflow is released under the MIT Licence. It is heavily based on Alfred-Workflow, also MIT-licensed.
  12. Hello, every time when I try to update Alfred 2 (I think since I bought it in March 2013) I get the message "Unable to verify". This bug has followed over with every Mac OS X update and clean install since then. I know about this thread: http://www.alfredforum.com/topic/2858-update-fails-with-unable-to-verify-for-every-release/ and I am sure the PHP on my Mac is fine (OS X 10.11.5). $ php -version PHP 5.5.34 (cli) (built: Apr 22 2016 19:16:58) ... $ whereis php /usr/bin/php $ php -r 'echo "Test";' Test The only way to update Alfred seems to be to download a fresh copy of Alfred from the website. This was a little annoying, but not so much that it was worth the efford to complain. But now with Alfred 3 there is no obvious download link on the website for Alfred 2 anymore. What is it, that this bug is so persistent? How to solve it? (I know I can upgrade to Alfred 3, and maybe I will do that in the future. But honestly Alfred 3 brings nothing new that I need. And also I'm in doubt this bug is fixed by upgrading.) Best regards, Brian
  13. Chrome History - Version 1.0 Open Recent Google Chrome Webpages Introduction: This Workflow will use PHP to make a cached copy of Google Chromes SQLite History file. Then you can easily search through your history by keyword. Example Usage: ch will return all your browsers history with the latest at the top. ch alfred will return all pages in your history that have the word alfred in the URL or Page Title. Alfred 2 Workflow Here: https://github.com/manifestinteractive/alfred-workflows/tree/master/Chrome%20History
  14. I'm trying to build a workflow that gathers information from a website which unfortunately does not have an API. Is it possible using the request method of the PHP Workflow Class to keep a session alive? I'd like to use a request to login, sending the required post fields, and then request another page that requires the previous authentication. Much thanks,
  15. Hi, I have a Script Filter with a keyword "KC" that populates results (using php and xml) with items I defined. This is working fine, except the fact that it also shows some unwanted items among my defined results. For example "Key Codes.app" - it shouldn't be there, but Alfred still shows them, probably because this app has letters K and C in it's name. This doesn't make sense. That's completely fine with me if Alfred show other apps like Komodo, Key Codes, Keychain Access, etc. when I start typing my keyword by typing "K". But when I finish typing my keyword "KC" it switches to my Workflow and displays results I defined. So why I still get "Key Codes.app" among these results? Thanks in advance, Romans
  16. What is Alphred? Alphred is a PHP library to aid in the creation of workflows for Alfred. Most of Alphred should work with PHP 5.3+ (OS X 10.6+), but some features need PHP 5.4+ (OS X 10.9+). Alphred generally needs Alfred v2.5+ to run. It's not quite complete because it needs some testing and a bit more documentation. Please help with the former. Features Simple AlfredXML generation for script filters, including extended XML attributes Create and manage configuration files in ini, json, or sqlite3 from a few lines of code Easy http requests with get or post, including data caching Use the system keychain to store and retrieve passwords Simple logging to single or multiple files as well as the console with variable log levels Filter results easily to match a query Make your script filters faster by using the cli-server (PHP 5.4+) with almost no change to your existing code Easily change dates into strings, exact (1 day, 3 hours, and 23 minutes ago) or fuzzy (yesterday) Use title case without any extra work fork php scripts to have them run in the background (and they know that they're in the background) send asynchonrous notifications with no external library know if the user's theme is light or dark (to set different icons) write complex workflows in 50-60 lines of code Example An example workflow (download) that takes your Github Username and Password and grabs a list of your repos and filters them by query is in the example folder. It uses the cli-server. You can see the well-documented code for the script filter and the action script. Without the comments, they reduce to about 60 lines of code together. ----- Mostly Original Post: It seems mostly complete now for a v1 release. It features easy script filter XML generation (with extended XML), an easy way to make http requests, easy results filtering (taken almost verbatim from Deanishe's Python library: thanks, Dean!), keychain interaction, AppleScript, text filters, and more. I've squashed all the bugs that I can find, but I still need to write up some tutorials on how to use it, but I figure that I'd make a pre-release available if people want to start playing with it. Do remember that I might change the API a bit before v1.0.0, and I might do that because I'd love to get some feedback on how the library feels or what doesn't work. For now, find v0.9.3-alpha on the Github release page. Just download the attached Alphred.phar file because that's all you need. To find automagically generated API docs, check out this page. There are links to both PHPDocumentor and Apigen generated docs. Let me know which ones you like better. There are also a few markdown files, for now, in the repository under the tutorial section, and there is also a very simple example workflow (or the script filter and action files) under the example directory. I'll update this post with more information as we go along, but, for now, that's what I got. Shawn
  17. So, this is just a quick tip: I you use strftime() to create a date/time string then remember to set the default time zone first, or PHP will throw an E_NOTICE error and the script will fail in Alfred.
  18. So I have the following PHP script which works well. I'm a newbie here, but trying to create a workflow where I can enter an argument, and it pings google, and returns the top result URL to me, copied to my clipboard. Like I said, on the last line, I do successfully return the top result, but not entirely sure how to hook up the rest of the workflow. Here you can see the workflow at the moment -> https://www.dropbox.com/s/pfo7b0uap41bd0g/Screenshot%202014-08-05%2016.13.02.png Any help would be much appreciated! function get_url_contents($url) { $crl = curl_init(); curl_setopt($crl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'); curl_setopt($crl, CURLOPT_URL, $url); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5); $ret = curl_exec($crl); curl_close($crl); return $ret; } $q = $argv[1]; //Get user-inputted argument $json = get_url_contents('http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=.$q.'); $data = json_decode($json); foreach ($data->responseData->results as $result) { $results[] = array('url' => $result->url, 'alt' => $result->title); } $url = $results[0]['url']; echo $url;
  19. Hi everyone! So apologies if this is a crazy question, but I'm having a little trouble understanding how to pass data between scripts. In my first php script, I successfully copy a url to the clipboard (that works great). What I'd like to do now is pass that url onto the second PHP script so I can use it in another way. 1. I'm not quite sure how to have the second script run AFTER the first one. 2. I'm not sure what variable to use to pass the output on, I know it's not {query}, but is there something similar?
  20. Hi All, I've noticed with my Spotify Mini Player workflow (PHP based) (http://www.alfredforum.com/topic/1892-spotify-mini-player-version-375-now-update-library-and-playlists-from-workflow/) that the first execution after some inactivity time is quite slow compared to next consecutive ones. So i tried to create a very basic workflow to show you this behavior. Grab it there: http://d.pr/f/2BKC Launch it with "ctrl+ENTER", it just displays a result with execution time. The first execution after some time, I get above 0.320 s whereas next ones are around 0.120 s If I execute it outside of Alfred, I don't get this behavior and I constantly get around 0.120 s Any idea what could cause this? Thanks
  21. Workflow to toggle Localhost Services (Start, Stop, Restart and Check Status). Currently support Nginx, MySQL, PHP-fpm and memcached. Download here: Github
  22. There are many different YouTube URL formats and they often include information about playlists, referrers, etc. A few examples: http://www.youtube.com/embed/T6DJcgm3wNY?rel=0 http://m.youtube.com/#/watch?v=T6DJcgm3wNY&feature=player_embedded&desktop_uri=%2Fwatch%3Fv%3DT6DJcgm3wNY%26feature%3Dplayer_embedded However, when I want to share a YouTube URL with someone I only want the basic URL that points directly to the video. In this case: Here's a workflow that takes any* YouTube URL and copies the basic URL to the clipboard. Download: basic-youtube-url.alfredworkflow * It might not cover every possible URL format, but so far I haven’t come across one that doesn’t work.
  23. An awesome way to filter through your favorited StackOverflow questions. Download it over on Github
  24. Hi, For my Spotify Mini Player workflow, I need to parse a library.json file which contains all spottily playlists of the user. The json data looks like: [ { "data" : { "discNumber" : 1, "album" : { "artist" : { "portrait" : "", "type" : "artist", "name" : "J-Boogie's Dubtronic Science", "uri" : "spotify:artist:76MRWSA9TZZg6s3Ijy7mxW" }, "availableForPlayback" : true, "availability" : 0, "cover" : "spotify:image:b9346fb9030ede38617e42eafd553d17fa7cf307", "year" : 2009, "type" : "album", "numTracks" : 0, "name" : "Soul Vibrations Dub Remixes", "uri" : "spotify:album:1QMgSZ88TOWU6ctJRAW4T6" }, "trackNumber" : 12, "availableForPlayback" : true, "uri" : "spotify:track:7AAR8NjH6RY4Dk5Ny5xQcb", "starred" : false, "artists" : [ { "portrait" : "", "type" : "artist", "name" : "J-Boogie's Dubtronic Science", "uri" : "spotify:artist:76MRWSA9TZZg6s3Ijy7mxW" } ], "popularity" : 23, "type" : "track", "isAd" : false, "availability" : 0, "isLocal" : false, "isPlaceholder" : false, "isExplicit" : false, "duration" : 290000, "isInvalid" : false, "isLoaded" : true, "name" : "1.4.u Dub - Feat. Ohmega Watts & Ragen Fykes" } } ] I am new to php (this is the first time i use it), so to parse this json file, I "loop" on all items and use strpos() to find matches: $json = file_get_contents($w->data() . "/library.json"); $json = json_decode($json,true); foreach ($json as $item) { if (strpos(strtolower($item['data']['album']['artist']['name']),strtolower($query)) !== false || strpos(strtolower($item['data']['album']['name']),strtolower($query)) !== false || strpos(strtolower($item['data']['name']),strtolower($query)) !== false) { // do something } }; This is working fine and I don't have any performances issues(i was surprised by the speed actually) with my Spotify library (2.2Mb JSON file with around 2200 tracks) But some users have more than 100 playlists, so the json file is about 15Mb To decode the json file, I had to add: ini_set('memory_limit', '128M' ); Questions: Is it a problem to set memory_limit like this? Is there a clever way to read/parse a JSON file? What about transforming the json data into a SQL db? Would it give better performances? I'm open to any suggestions :-) Cheers
  25. I think this will be an easily rectifiable bug, but I haven't been able to sort it out myself. I need to change the line to also somehow incorporate the source since sometimes the only available info is under "Entries" rather than "PrincipalTranslations". I tried doubling up the foreach loops (repeating the relevant part of the script twice), but despite the fact that both loops work on their own, when I put one after the other it just stalls for awhile and then fails. I also tried inserting an if statement with the following approach: but there I think I'm making a syntax error that I don't know how to overcome. For reference, here's the whole script: Thanks so much for all your help.
  • Create New...