Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

Recipe

> DevOps
Open source

Collection of PHP Functions

671 stars0 likes1 views
WebsiteGitHub

About

Collection of PHP Functions

Recipe :book:

Collection of PHP Functions

[](https://styleci.io/repos/65232201)

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:

bash
composer require ngfw/recipe

Create new file and start using the Recipes

php
 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:

php
$favIcon = Recipe::getFavicon("http://youtube.com/");

echo $favIcon;
// outputs: 

Getting remote website Favicon with HTML attributes:

php
$favIcon = Recipe::getFavicon(
          "http://youtube.com/",
          array(
            "class" => "favImg"
          )
);
echo $favIcon;
//outputs: 

QRcode

Generating QR code

php
$QRcode = Recipe::getQRcode("ngfw Recipe");
echo $QRcode;  
//outputs: 

Generating QR code and adding HTML attributes:

php
$QRcode = Recipe::getQRcode(
    "ngfw Recipe",
    $width = 350,
    $height = 350,
    $attributes = array(
        "class" => "QRCode"
    )
);
echo $QRcode;  
// outputs: 

File extension

php
$ext = Recipe::getFileExtension(__FILE__); // replace '__FILE__' with your filename
echo $ext;
//outputs: php

Gravatar

Getting Gravatar:

php
$Gravatar = Recipe::getGravatar("[email protected]");
echo $Gravatar;
// outputs: 

Getting Gravatar with HTML attributes:

php
$Gravatar = Recipe::getGravatar(
    "[email protected]",
    $size = 200,
    $default = 'monsterid',
    $rating = 'x',
    $attributes = array(
        "class" => "Gravatar"
    )
);
echo $Gravatar;
//Outputs: '

Creating Link Tags

Simple Link:

php
$linkTags = Recipe::createLinkTag("google.com");
echo $linkTags;   
//outputs: google.com

Link with title:

php
$linkTags = Recipe::createLinkTag("google.com", "Visit Google");
echo $linkTags;   
//outputs: Visit Google

Link with title and HTML attributes:

php
$linkTags = Recipe::createLinkTag("google.com", "Visit Google", array(
    "class" => "outgoingLink"
));
echo $linkTags;   
//outputs: Visit Google

Validate email address

php
$isValid = Recipe::validateEmail("[email protected]");
var_dump($isValid);
// outputs: true (bool)

Check for temporary Email addresses:

php
$isValid = Recipe::validateEmail('[email protected]', $tempEmailAllowed = false);
var_dump($isValid);
// outputs: false (bool)

Validate URL

php
$isValid = Recipe::validateURL("http://github.com/");
var_dump($isValid);
// outputs: true (bool)

RSS Reader

php
$rssArray = Recipe::rssReader("https://github.com/ngfw/Recipe/commits/master.atom");
var_dump($rssArray);
// Outputs feed as an array

Object to Array

php
$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

php
$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

php
$array = array(
    "foo" => "bar",
    "baz" => "qux",
);
$string = Recipe::arrayToString($array);
echo $string;
// outputs: foo="bar" baz="qux"

HEX to RGB

php
$rgb = Recipe::hex2rgb("#FFF");
echo $rgb;
// outputs: rgb(255, 255, 255)

RGB to HEX

php
$hex = Recipe::rgb2hex("rgb(123,123,123)");
// outputs: #7b7b7b

Color Name to HEX

php
$hex = Recipe::colorNameToHex('red');
// outputs: #FF0000

Generate Random Password

php
$randomPass = Recipe::generateRandomPassword(10);
echo $randomPass;
// outputs: 10 random character string

Simple Encode

php
$encodedString = Recipe::simpleEncode("php recipe");
echo $encodedString;
// outputs: qcnVhqjKxpuilw==

Simple Decode

php
$decodedString = Recipe::simpleDecode("qcnVhqjKxpuilw==");
echo $decodedString;
// outputs: php recipe

Generate Server Specific Hash

php
$serverHash = Recipe::generateServerSpecificHash();
echo $serverHash;
// outputs: d41d8cd98f00b204e9800998ecf8427e

Detect HTTPS

This method checks for $_SERVER['HTTPS']

php
$isHttps = Recipe::isHttps();
var_dump($isHttps);
// outputs: bool

Detect AJAX

This method checks for $_SERVER['HTTP_X_REQUESTED_WITH']

php
$isAjax = Recipe::isAjax();
var_dump($isAjax);
// outputs: bool

Check if number is odd

php
$isNumberOdd = Recipe::isNumberOdd(5);
// outputs: bool

Check if number is even

php
$isNumberEven = Recipe::isNumberEven(8);
var_dump($isNumberEven);
// outputs: bool

Get Current URL

php
$currentURL = Recipe::getCurrentURL();
var_dump($currentURL);
// outputs: current Request URL

Get Client IP

php
$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

php
$isMobile = Recipe::isMobile();
var_dump($isMobile);
// outputs: true or false

Get Browser

php
$Browser = Recipe::getBrowser();
echo $Browser
// outputs: Browser Details

Get Client Location

php
$user_location = Recipe::getClientLocation();
echo $user_location;
// outputs: Users Location

Number To Word conversion

php
$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

php
$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

php
$minutes  = 60 * 24 * 2;
$duration = Recipe::minutesToText($minutes);
echo $duration;
// outputs: 2 days
// Recipe::minutesToText($minutes, $returnAsWords = true);
// will return: two days

Hours To Text

php
$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

Shorten String

php
$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

CURL

Simple GET example:

php
$data = Recipe::curl("https://api.ipify.org");
var_dump($data);
// outputs: Curl'ed Data

POST Example:

php
$CurlPOST = Recipe::curl("http://jsonplaceholder.typicode.com/posts", $method = "POST", $data = array(
    "title"  => 'foo',
    "body"   => 'bar',
    "userId" => 1,
));

Custom Headers:

php
$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
//}

Basic authentication with CURL:

php
$curlBasicAuth = Recipe::curl(
    "http://jsonplaceholder.typicode.com/posts",
    $method = "GET",
    $data = false,
    $header = false,
    $returnInfo = false,
    $auth = array(
       'username' => 'your_login',
       'password' => 'your_password',
    )
);

Expand Short URL

php
$shortURL = "https://goo.gl/rvDnMX";
$expandedURL = Recipe::expandShortUrl($shortURL);
echo $expendedURL;
// outputs: https://github.com/ngfw/Recipe

Get Alexa Rank

php
$AlexaRank = Recipe::getAlexaRank("github.com");
echo $AlexaRank;
// outputs: Current alexa ranking as position number (example: 52)

Shorten URL

php
$TinyUrl = Recipe::getTinyUrl("https://github.com/ngfw/Recipe");
echo $TinyUrl;
// outputs: http://tinyurl.com/h2nchjh

Get Keyword Suggestions From Google

…

WIKI Search

php
$wiki = Recipe::wikiSearch("Tbilisi");
var_dump($wiki);
// outputs: data from wikipedia

Notification

php
$notification = Recipe::notification("Test Successful");
echo $notification;
// outputs: 

// NOTE: possible notifications types: success, warning, error and info
// Type is passed as a second parameter

Auto Embed

php
$string = "Checkout Solomun, Boiler Room at https://www.youtube.com/watch?v=bk6Xst6euQk";
echo Recipe::autoEmbed($string);
// outputs:
// Checkout Solomun, Boiler Room at
// supported providers are: youtube.com, blip.tv, vimeo.com, dailymotion.com, flickr.com, smugmug.com, hulu.com, revision3.com, wordpress.tv, funnyordie.com, soundcloud.com, slideshare.net and instagram.com

Make Clickable Links

php
$string = "Check PHP Recipes on https://github.com/ngfw/Recipe";
$clickable = Recipe::makeClickableLinks($string);
echo $clickable;
// outputs:
// Check PHP Recipes on https://github.com/ngfw/Recipe

Debug

var_dump() alternative

php
$string = "Test me";
Recipe::debug($string);

Get Referer

Get the referer page (last page visited)

php
$referrer = Recipe::getReferer();
echo $referer ;
// outputs an url (http://mywebsite.com/page1)

Ordinal

php
for($i=1;$i

HTML Page Title

    Hello Friend,

will output:

xml
HTML Page Title Hello Friend,

PR

php
Recipe::pr( array("he","ll","oo") );

will output:

xml
Array
(    
    [0] => he
    [1] => ll
    [2] => oo
)

Bytes To Human Readable Size

php
Recipe::bytesToHumanReadableSize( "17179869184" );

will output:

xml
16 GB

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPfunctionrecipesstandalonestatic

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理