Getting Url Segment
Get the url segment using segment() method:
use Cygnite\Common\UrlManager\Url; http://www.cygniteframework.com/projects/index.php/users/list/23 http://www.cygniteframework.com/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.
It returns http://www.cygniteframework.com/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.
Getting Referrer Url
In some case you may want to check which page user visit from. You can find the referrer url as below.
Use encode() function to encode your url.
Url::encode('url-to-encode'); // returns encoded url
Use decode() function to decode your encoded url.