How to Get the Header Data CakePHP or PHP?

I Personally Tried a lot for getting the posted header data in cakephp.

The Header data required to check the posted token. Token validation , to check the posted request is valid or not.

Finally I found the Solution.
PHP It self has a function named, getallheaders()

Syntax: getallheaders ( void ) : array
Description: Fetches all HTTP headers from the current request.

Return Values::
An associative array of all the HTTP headers in the current request, or FALSE on failure.

Example #1 getallheaders() example

$headers = getallheaders();
foreach( $headers as $name => $value) {
     echo "$name: $value\n";

Example: Received Data:

     [Host] =>
     [Connection] => keep-alive
     [Content-Length] => 264
     [auth_token] => 20dea7c13dada345dgf80815d3546393a98
     [device_id] => adada23456
     [Cache-Control] => no-cache
     [Origin] => chrome-extension://fhbjgjbdggehcddcbncdddomop
     [User-Agent] => Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
     [Postman-Token] => 2d5b612b-e2db-1202-50f1-925cb2f8fa05
     [Content-Type] => multipart/form-data; boundary=----WebKitFormBoundarySssj4jB1U7xNxnHy
     [Accept] => */*
     [Accept-Encoding] => gzip, deflate, br
     [Accept-Language] => en-GB,en-US;q=0.9,en;q=0.8
     [Cookie] => PHP=lm68fsfbhedsvbb6b96


How to Create Unique Number in PHP?


$mt_rand = mt_rand(1000000000, 9999999999); 
echo $mt_rand;


$unique_id = uniqid();
echo $unique_id;
 uniqid( prefix, more_entropy ) 

Can be useful, for instance, if you generate identifiers simultaneously on several hosts that might happen to generate the identifier at the same microsecond.

With an empty prefix, the returned string will be 13 characters long. If more_entropy is TRUE, it will be 23 characters.

If set to TRUE, uniqid() will add additional entropy (using the combined linear congruential generator) at the end of the return value, which increases the likelihood that the result will be unique.



$mt_rand = mt_rand(1000000000, 9999999999);
$timestamp = time();
$temp = $mt_rand + $timestamp;
$temp2= substr($tmp, 0,10);

echo $temp2;

How to check installed cakephp version?

How to check installed cakephp version?

Project Structure::

-- app
-- lib
-- plugins
-- vendors
-- index.php

Open The VERSION.txt file. There You will find Like below. Last line show the version of cakephp
Here, You can see, VERSION is 2.8.0


// +--------------------------------------------------------------------------------------------+ //
// CakePHP Version
// Holds a static string representing the current version of CakePHP
// CakePHP(tm) : Rapid Development Framework (
// Copyright (c) Cake Software Foundation, Inc. (
// Licensed under The MIT License
// Redistributions of files must retain the above copyright notice.
// @copyright Copyright (c) Cake Software Foundation, Inc. (
// @link
// @package Cake
// @since CakePHP(tm) v 0.2.9
// @license MIT License
// +--------------------------------------------------------------------------------------------+ //