Skip to content

Commit

Permalink
Added pretty url rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
Schanihbg committed Mar 28, 2017
1 parent 8acef99 commit 1ac51db
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* Config file for url.
*/
return [
// Defaults to use when creating urls.
//"siteUrl" => null,
//"baseUrl" => null,
//"staticSiteUrl" => null,
//"staticBaseUrl" => null,
//"scriptName" => null,
"urlType" => \Anax\Url\Url::URL_CLEAN,
//"urlType" => \Anax\Url\Url::URL_APPEND,
];
24 changes: 24 additions & 0 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@
var_dump($request);

echo "Done";

// Create and init an instance of url.
$url = new \Anax\Url\Url();

// Set default values from the request object.
$url->setSiteUrl($request->getSiteUrl());
$url->setBaseUrl($request->getBaseUrl());
$url->setStaticSiteUrl($request->getSiteUrl());
$url->setStaticBaseUrl($request->getBaseUrl());
$url->setScriptName($request->getScriptName());

// Update url configuration with values from config file.
$url->configure("url.php");
$url->setDefaultsFromConfiguration();

// Create some urls.
$aUrl = $url->create("");
echo "<p><a href='$aUrl'>The index url, home</a> ($aUrl)";

$aUrl = $url->create("some/route");
echo "<p><a href='$aUrl'>Url to some/route</a> ($aUrl)";

$aUrl = $url->create("some/where/some/route");
echo "<p><a href='$aUrl'>Another url to some/where/some/route</a> ($aUrl)";

0 comments on commit 1ac51db

Please sign in to comment.