1. Go to this page and download the library: Download ngfw/recipe 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/ */
ngfw / recipe example snippets
gfw\Recipe as Recipe;
$suggestion = Recipe::getKeywordSuggestionsFromGoogle("home");
print_r($suggestion);
//
//Array
//(
// [0] => home depot
// [1] => home goods
// [2] => home depot near me
// [3] => homes for sale
// [4] => homeaway
// [5] => homes for rent
// [6] => home advisor
// [7] => home depot credit card
// [8] => home depot coupons
// [9] => homeland
//)
$currentURL = Recipe::getCurrentURL();
var_dump($currentURL);
// outputs: current Request URL
$ClientsIP = Recipe::getClientIP();
echo $ClientsIP;
//OR
// Return Proxy IP if user is behind it
//$ClientsIP = Recipe::getClientIP("HTTP_CLIENT_IP"); //'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED', ...
// outputs: IP address
$isMobile = Recipe::isMobile();
var_dump($isMobile);
// outputs: true or false
$number = "864210";
$number_in_words = Recipe::numberToWord($number);
echo $number_in_words;
// outputs: eight hundred and sixty-four thousand, two hundred and ten
$seconds = "864210";
$number_in_words = Recipe::secondsToText($seconds);
echo $number_in_words;
// outputs: 1 hour and 10 seconds
// Recipe::secondsToText($seconds, $returnAsWords = true);
// will return: one hour and ten seconds
$minutes = 60 * 24 * 2;
$duration = Recipe::minutesToText($minutes);
echo $duration;
// outputs: 2 days
// Recipe::minutesToText($minutes, $returnAsWords = true);
// will return: two days
$hours = 4.2;
$duration = Recipe::hoursToText($hours);
echo $duration;
// outputs: 4 hours and 12 minutes
// Recipe::hoursToText($hours, $returnAsWords = true);
// will return: four hours and twelve minutes
$string = "The quick brown fox jumps over the lazy dog";
$shortenString = Recipe::shortenString($string, 20);
// output: The quick brown f...
// Recipe::shortenString($string, 20, $addEllipsis = false);
// output: "The quick brown fox ", NOTE last space
// Recipe::shortenString($string, 20, $addEllipsis = false, $wordsafe = true);
// output: "The quick brown fox", NOTE, will not break in the middle of the word
$data = Recipe::curl("https://api.ipify.org");
var_dump($data);
// outputs: Curl'ed Data
$curlWithHeaders = Recipe::curl("http://jsonplaceholder.typicode.com/posts", $method = "GET", $data = false, $header = array(
"Accept" => "application/json",
), $returnInfo = true);
// NOTE $returnInfo argument
// Result will be returned as an array, $curlWithHeaders={
// info => containing curl information, see curl_getinfo()
// contents => Data from URL
//}
$wiki = Recipe::wikiSearch("Tbilisi");
var_dump($wiki);
// outputs: data from wikipedia
$notification = Recipe::notification("Test Successful");
echo $notification;
// outputs: <div style="display: block;padding: 0.5em;border: solid 1px;border-radius: 0.125em;margin-bottom: 1em; border-color: #a6d9f2;color: #0a5276;background-color: #e7f6fd;" role="alert">Test Successful</div>
// NOTE: possible notifications types: success, warning, error and info
// Type is passed as a second parameter