Download the PHP package gokulsrinivas/sangria without Composer
On this page you can find all versions of the php package gokulsrinivas/sangria. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sangria
Sangria
A Set of lightweight PHP libraries to make your life easier.
FAQ: Why the name Sangria?
Ans: Because I like this song and I like to drink/eat fruits.
Installation
- Add
"gokulsrinivas/sangria":"dev-master"
to"require"
in yourcomposer.json
. - Do a
composer install
- If you're not using this in a framework like laravel, be sure to
include "vendor/autoload.php"
in your file.vendor
is the folder that is created after the composer install. use Sangria\JSONResponse
/IMAPAuth
/LDAPAuth
/HelperFunctions
- See usage below.
- Write cleaner code.
- Feel Awesome.
- Build cool stuff.
- Happy coding!
Usage
Sangria\JSONResponse
This class is helpful to API Developers who need to return JSON representations of strings, objects, collections etc.
This class follows the following JSON structure.
- Include the class with
use Sangria\JSONResponse;
- Definition
JSONResponse::response($status_code=400,$message=NULL,$strict_mode=false)
- The
$status_code
can be HTTP status codes or your own custom status codes. - If the
$status_code
is a HTTP status code and the message isNULL
, a default reason phrase is added. (If$strict_mode
isfalse
(default) ) - If the
$strict_mode
is set totrue
, the data given as$message
is encoded. So,NULL
is encoded asnull
. - The
$status_code
defaults to 400. Sangria\JSONResponse
can be safely used in Laravel as all eloquent models and collections can be passed as$message
.
Sample Code
Output
Sangria\IMAPAuth
This class is useful for developers who just need to authenticate a username/password combo via IMAP.
- Include the class with
use Sangria\IMAPAuth;
- Definition
IMAPAuth::auth($user_name,$user_pass,$imap_option="/imap/ssl/novalidate-cert",$imap_retries=0)
- The
$imap_option
is a string beginning with/
listed as Optional flags for names as given in the page for imap on php.net. - If the
$imap_retries
is the number of retries.
Configuration
- Please set the
__SANGRIA_IMAP_SERVER_ADDR__
and__SANGRIA_IMAP_SERVER_PORT__
to the desired address and port inconfig.php
invendor/gokulsrinivas/sangria
if installed via composer.
Sample Code
Output
Sangria\LDAPAuth
This class is useful for developers who just need to authenticate a username/password combo via LDAP.
- Include the class with
use Sangria\LDAPAuth;
- Definition
LDAPAuth::auth($user_name,$user_pass)
Configuration
- Please set the
__SANGRIA_LDAP_SERVER_ADDR__
to the desired address inconfig.php
invendor/gokulsrinivas/sangria
if installed via composer.
Sample Code
Output
Sangria\HelperFunctions
This class is helpful for development and debugging. This includes dd()
, ddp()
and isEmail()
functions to speed up your development.
* dd()
While debugging, you might need to var_dump()
the variable and die()
. This function helps you to do just that.
Source Code
Output
* ddp()
While debugging, you might need to var_dump()
the variable and die()
. If your objects are complex or if you want to use the dumped data in javascript, you might need it in JSON format. This function helps you to do just that.
Source Code
Output
* isEmail()
This function is useful to check whether a given string is a valid email.
Source Code
Output
Contribute
There can never be enough tests. Feel free to write more test cases!
If you want to add features, improve them, or report issues, feel free to send a pull request! Please include tests for new features.