Cygnite - A Modern Toolkit For Web Developers

The Elegant Way of Building Full-Featured Web Applications

Cygnite Dynamic Routing

Url Manager

Documentation

Url Manager

Getting Url Segment

Get the url segment using segment() method:


 use Cygnite\Common\UrlManager\Url;

 /projects/index.php/users/list/23
 /projects/users/list/23
 

 echo Url::segment(2); //output: list


Url segment always counts from your front controller "index.php". It start counting if index.php is available in url or else from your root path. The above url segment will print "list" as result.

Getting Base Path Of Your Application

Though there is an option to set base url of your application in src/Apps/Configs/application.php, but you don't require to set. Cygnite is intelligent enough to guess your application base url and set it up for you while booting. You can get application base path as below.



  echo Url::getBase();


It returns /projects/ as result.

Redirecting To Another Page

You can redirect one page to another using below code.



   Url::redirectTo('controller-name.action-name'); 
    
   or 

   Url::redirectTo('controller-name/action-name');


Refresh/Reloading The Page

After performing some operation you may want to reload the current page. You can pass second parameter as "refresh" in the redirectTo method to reload the current page.


 Url::redirectTo('user/index', 'refresh');


Getting Referrer Url

In some case you may want to check which page user visit from. You can find the referrer url as below.



   Url::referredFrom();


Encoding Url

Use encode() function to encode your url.



 Url::encode('url-to-encode'); // returns encoded url

Decoding Url

Use decode() function to decode your encoded url.


 Url::decode('url-to-decode');

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