PHP code example of gokulsrinivas / sangria

1. Go to this page and download the library: Download gokulsrinivas/sangria 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/ */

    

gokulsrinivas / sangria example snippets




use Sangria\JSONResponse;

$status_code = 200;
$message = new StdClass();
$message->prop1 = "asdf";
$message->prop2 = array("asdf");
$message->prop3 = array(array("asdf"));
$message->prop4 = true;

$response_string = JSONResponse::response($status_code,$message);
echo $response_string;



use Sangria\IMAPAuth;

if(IMAPAuth::auth('username','********'))
{
	echo "Authenticated";
}
else
{
	echo "Authentication Failed";
}



use Sangria\LDAPAuth;

if(LDAPAuth::auth('username','********'))
{
	echo "Authenticated";
}
else
{
	echo "Authentication Failed";
}


use Sangria\HelperFunctions;

$a = 4*"2";
Helperfunctions::dd($a);
echo "done";


use Sangria\HelperFunctions;

$a = new StdClass();

$a->name = "Hello";
$a->surname = "World";
$a->nicknames = ["Hi",["My","Name","Is"],"Sangria"];
$a->adult = true;
$a->balance = 2334.34;
$a->age = 19;

Helperfunctions::ddp($a);
echo "done";


use Sangria\HelperFunctions;

$email_string = "hi    @hi.com";

if(Helperfunctions::isEmail($email_string))
{
	echo "Valid Email";
}
else
{
	echo "Invalid Email";
}