Skip to content

Commit 6b77b66

Browse files
committed
$_ENV might not be populated in all PHP setups, use getenv() #5
1 parent 71fce78 commit 6b77b66

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
// check for username
4-
if (empty($_ENV['username'])) {
4+
if (false === getenv('username')) {
55
echo json_encode([
66
'items' => [[
77
"arg" => "https://www.alfredapp.com/help/workflows/advanced/variables/",
@@ -13,7 +13,7 @@
1313
exit(1);
1414
}
1515

16-
$cache_path = $_ENV['alfred_workflow_cache'];
16+
$cache_path = getenv('alfred_workflow_cache');
1717
$cache_response = $cache_path . '/cache.json';
1818
$cache_icons = $cache_path . '/icons/';
1919

@@ -25,10 +25,10 @@
2525
mkdir($cache_icons);
2626
}
2727

28-
$username = trim($_ENV['username']); // set inside workflow variables
29-
$token = trim($_ENV['token']); // set inside workflow variables
28+
$username = trim(getenv('username')); // set inside workflow variables
29+
$token = trim(getenv('token')); // set inside workflow variables
3030
$starred_url = sprintf('https://api.github.com/users/%s/starred', $username);
31-
$cache_ttl = (empty($_ENV['cache_ttl'])) ? 3600 * 24 : (int) $_ENV['cache_ttl']; // in seconds
31+
$cache_ttl = (false === getenv('cache_ttl')) ? 3600 * 24 : (int) getenv('cache_ttl'); // in seconds
3232
$query = trim($argv[1]); // optional text search
3333
$http_status = 200; // default status code, so when using cache it doesn't run into error handling
3434

0 commit comments

Comments
 (0)