Cygnite - A Modern Toolkit For Web Developers

The Elegant Way of Building Full-Featured Web Applications

Cygnite Dynamic Routing

Input

Documentation

Input

Getting the Input Instance

Accessing your post inputs are very easy and don't worry about security, cygnite escape your string internally. Create Input instance to retrieve user input data.
For Example :

 
 use Cygnite\Common\Input\Input;

 $input = Input::make(function ($input) 
 {
      return $input;
 });
 
 Or 

 $input = Input::make();
    

Checking Post Value Existence

Verify form posted or not using hasPost() method.

 
  <input type="submit" name="btnSubmit" value="Save" />

  if ($input->hasPost('btnSubmit') == true)  {
    ................
  }  

 
 

Retrieving All Post Values

Retrieving particular field value


    if ($input->hasPost('btnSubmit') == true)  {
        echo $input->post('name'); // Cygnite PHP Framework
    }

Retrieving Field's Multidimensional Array Value

 

    if ($input->hasPost('btnSubmit') == true)  {
        echo $input->post('user.name'); // Sanjoy Dey 
    }
 

Above code equivalent of using $_POST['user']['name'];

Retrieving Only Required Input

You may don't want to get all the post values, except a field want to retrieve all post array. Then you may use except() method to escape field value from post values.

 

 if ($input->hasPost('btnSubmit') == true)  {
     show($input->except('address')->post()); // Give you all post values except "address" field. 
 }     

Checking Is Ajax Request

You may want to check if incoming request is AJAX request or not. You can achieve it as below.

 
  if ($input->isAjax()) {     
     // Ajax Request
  }
 
    

Getting JSON Input

Some application where you send ajax request we pass JSON value to controller, input post or get may not give you request value. IN such case you can use json() method to get JSON object values.

 
  $json = $input->json();
  
  echo $json->email; 
    

Cookie Manager

Getting Cookie Instance

In the below example shown how to get cookie instance to manipulate cookies.

 
  use Cygnite\Common\Input\CookieManager\Cookie;

  $cookie = Cookie::create(function ($cookie) 
  {
     return $cookie;                 
  });  

  Or 

  $cookie = Cookie::create(); 
 
    

Setting Cookie

We can set cookies as below.

 

 $cookie->name('foo')
       ->value('Bar')
       ->expire('+1 Days')
       ->path('/')
       ->domain('www.cygniteframework.com')
       ->secure(false)
       ->httpOnly(true)
       ->store();

 or

 $cookie = Cookie::create(function ($cookie) 
 {
     $cookie->name('foo')
            ->value('bar')
            ->expire((time()+3600))
            ->path('/')
            ->store();

     return $cookie;
 });


Verifying Cookie Existence

 
 $cookie->has('foo');


Getting Cookie Value Using The Key

We can verify if cookie is set using has() method and it will return boolean value. If returning true we can get the cookie value using get() method.

 
 $cookie->get('foo');

 

Destroying Cookie

Destroy unwanted cookies by name.

 
  $cookie->destroy('foo');

  
Follow Us On Facebook Twitter Google+ Linkedin
Released Under The MIT Public License. Copyrights @2012-2017. Powered by- Sanjoy Dey Productions.