1. Go to this page and download the library: Download gajus/director 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/ */
gajus / director example snippets
/**
* @param string $url Default route URL.
*/
$locator = new \Gajus\Director\Locator('http://gajus.com/');
/**
* @todo Check if query string is om/');
# null
/**
* Get absolute URL using either of the predefined routes.
* Requested resource path is appended to the route.
*
* @param string $path Relavite path to the route.
* @param string $route Route name.
*/
$locator->url();
# http://gajus.com/
// Get URL relative to the default route:
$locator->url('post/1');
# http://gajus.com/post/1
// Get URL for the "static" route:
$locator->url(null, 'static');
# http://static.gajus.com/
// Get URL relative to the "static" route:
$locator->url('css/frontend.css', 'static');
# http://static.gajus.com/css/frontend.css
/**
* Redirect user agent to the given URL.
*
* If no $url is provided, then attempt to redirect to the referrer
* or (when referrer is not available) to the default route.
*
* @see http://benramsey.com/blog/2008/07/http-status-redirection/
* @param string|null $url Absolute URL
* @param int|null $response_code HTTP response code. Defaults to 303 when request method is POST, 302 otherwise.
* @return null
*/
$locator->location();
# null (script execution terminated)
// Redirect to the default path with status code 307:
$locator->location(null, 307);
# null (script execution terminated)
// Redirect to an arbitrary URL:
$locator->location('http://gajus.com');
# null (script execution terminated)