Recipe
Collection of PHP Functions
Install / Use
/learn @ngfw/RecipeREADME
Recipe :book:
Collection of PHP Functions
Table of Contents
- 🚀 Quick Start
- Favicon
- QRcode
- File extension
- Gravatar
- Creating Link Tags
- Validate email address
- Validate URL
- RSS Reader
- Object to Array
- Array to Object
- Array to String
- HEX to RGB
- RGB to HEX
- Color Name to HEX
- Generate Random Password
- Simple Encode
- Simple Decode
- Generate Server Specific Hash
- Detect HTTPS
- Detect AJAX
- Check if number is odd
- Check if number is even
- Get Current URL
- Get Client IP
- Detect Mobile
- Get Browser
- Get Client Location
- Number To Word conversion
- Seconds To Text
- Minutes To Text
- Hours To Text
- Shorten String
- CURL
- Shorten URL
- Get Alexa Rank
- Get Tiny URL
- Get Keyword Suggestions From Google
- WIKI Search
- Notification
- Auto Embed
- Make Clickable Links
- 🔧 Debug
- Get Referer
- Compress Page
- Ordinal
- Number Of Days In Month
- pr
- Bytes To Human Readable Size
Quick Start
Run in your terminal:
composer require ngfw/recipe
Create new file and start using the Recipes
<?php
require "vendor/autoload.php";
use ngfw\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
//)
Favicon
Getting remote website Favicon:
$favIcon = Recipe::getFavicon("http://youtube.com/");
echo $favIcon;
// outputs: <img src="https://www.google.com/s2/favicons?domain=youtube.com/" />
<img src="https://www.google.com/s2/favicons?domain=youtube.com/" />
Getting remote website Favicon with HTML attributes:
$favIcon = Recipe::getFavicon(
"http://youtube.com/",
array(
"class" => "favImg"
)
);
echo $favIcon;
//outputs: <img src="https://www.google.com/s2/favicons?domain=youtube.com/" class="favImg" />
<img src="https://www.google.com/s2/favicons?domain=youtube.com/" class="favImg" />
QRcode
Generating QR code
$QRcode = Recipe::getQRcode("ngfw Recipe");
echo $QRcode;
//outputs: <img src="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=ngfw+Recipe" />
<img src="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=ngfw+Recipe" />
Generating QR code and adding HTML attributes:
$QRcode = Recipe::getQRcode(
"ngfw Recipe",
$width = 350,
$height = 350,
$attributes = array(
"class" => "QRCode"
)
);
echo $QRcode;
// outputs: <img src="http://chart.apis.google.com/chart?chs=350x350&cht=qr&chl=ngfw+Recipe" class="QRCode" />
<img src="http://chart.apis.google.com/chart?chs=350x350&cht=qr&chl=ngfw+Recipe" class="QRCode" />
File extension
$ext = Recipe::getFileExtension(__FILE__); // replace '__FILE__' with your filename
echo $ext;
//outputs: php
Gravatar
Getting Gravatar:
$Gravatar = Recipe::getGravatar("gejadze@gmail.com");
echo $Gravatar;
// outputs: <img src="http://www.gravatar.com/avatar.php?gravatar_id=9d9d478c3b65d4046a84cf84b4c8bf46&default=mm&size=80&rating=g" width="80px" height="80px" />
Getting Gravatar with HTML attributes:
$Gravatar = Recipe::getGravatar(
"gejadze@gmail.com",
$size = 200,
$default = 'monsterid',
$rating = 'x',
$attributes = array(
"class" => "Gravatar"
)
);
echo $Gravatar;
//Outputs: <img src="http://www.gravatar.com/avatar.php?gravatar_id=9d9d478c3b65d4046a84cf84b4c8bf46&default=monsterid&size=200&rating=x" width="200px" height="200px" class="Gravatar" />'
Creating Link Tags
Simple Link:
$linkTags = Recipe::createLinkTag("google.com");
echo $linkTags;
//outputs: <a href="google.com">google.com</a>
Link with title:
$linkTags = Recipe::createLinkTag("google.com", "Visit Google");
echo $linkTags;
//outputs: <a href="google.com" title="Visit Google" >Visit Google</a>
Link with title and HTML attributes:
$linkTags = Recipe::createLinkTag("google.com", "Visit Google", array(
"class" => "outgoingLink"
));
echo $linkTags;
//outputs: <a href="google.com" title="Visit Google" class="outgoingLink">Visit Google</a>
Validate email address
$isValid = Recipe::validateEmail("user@gmail.com");
var_dump($isValid);
// outputs: true (bool)
Check for temporary Email addresses:
$isValid = Recipe::validateEmail('user@fakeinbox.com', $tempEmailAllowed = false);
var_dump($isValid);
// outputs: false (bool)
Validate URL
$isValid = Recipe::validateURL("http://github.com/");
var_dump($isValid);
// outputs: true (bool)
RSS Reader
$rssArray = Recipe::rssReader("https://github.com/ngfw/Recipe/commits/master.atom");
var_dump($rssArray);
// Outputs feed as an array
Object to Array
$obj = new stdClass;
$obj->foo = 'bar';
$obj->baz = 'qux';
$array = Recipe::objectToArray($obj);
var_dump($array);
// outputs:
// array(2) {
// ["foo"]=>
// string(3) "bar"
// ["baz"]=>
// string(3) "qux"
// }
Array to Object
$array = array(
"foo" => "bar",
"baz" => "qux",
);
$obj = Recipe::arrayToObject($array);
// outputs:
// object(stdClass)#15 (2) {
// ["foo"]=>
// string(3) "bar"
// ["baz"]=>
// string(3) "qux"
// }
Array to String
$array = array(
"foo" => "bar",
"baz" => "qux",
);
$string = Recipe::arrayToString($array);
echo $string;
// outputs: foo="bar" baz="qux"
HEX to RGB
$rgb = Recipe::hex2rgb("#FFF");
echo $rgb;
// outputs: rgb(255, 255, 255)
RGB to HEX
$hex = Recipe::rgb2hex("rgb(123,123,123)");
// outputs: #7b7b7b
Color Name to HEX
$hex = Recipe::colorNameToHex('red');
// outputs: #FF0000
Generate Random Password
$randomPass = Recipe::generateRandomPassword(10);
echo $randomPass;
// outputs: 10 random character string
Simple Encode
$encodedString = Recipe::simpleEncode("php recipe");
echo $encodedString;
// outputs: qcnVhqjKxpuilw==
Simple Decode
$decodedString = Recipe::simpleDecode("qcnVhqjKxpuilw==");
echo $decodedString;
// outputs: php recipe
Generate Server Specific Hash
$serverHash = Recipe::generateServerSpecificHash();
echo $serverHash;
// outputs: d41d8cd98f00b204e9800998ecf8427e
Detect HTTPS
This method checks for $_SERVER['HTTPS']
$isHttps = Recipe::isHttps();
var_dump($isHttps);
// outputs: bool
Detect AJAX
This method checks for $_SERVER['HTTP_X_REQUESTED_WITH']
$isAjax = Recipe::isAjax();
var_dump($isAjax);
// outputs: bool
Check if number is odd
$isNumberOdd = Recipe::isNumberOdd(5);
// outputs: bool
Check if number is even
$isNumberEven = Recipe::isNumberEven(8);
var_dump($isNumberEven);
// outputs: bool
Get Current URL
$currentURL = Recipe::getCurrentURL();
var_dump($currentURL);
// outputs: current Request URL
Get Client IP
$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
Detect Mobile
$isMobile = Recipe::isMobile();
var_dump($isMobile);
// outputs: true or false
Get Browser
$Browser = Recipe::getBrowser();
echo $Browser
// outputs: Browser Details
Get Client Location
$user_location = Recipe::getClientLocation();
echo $user_location;
// outputs: Users Location
Number To Word conversion
$number = "864210";
$number_in_words = Recipe::numberToWord($number);
echo $number_in_words;
// outputs: eight hundred and sixty-four thousand, two hundred and ten
Seconds To Text
$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 To Text
$minutes = 60 * 24 * 2;
$duration = Recipe::minutesToText($minutes);
echo $duration;
// output
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
