Simple Routing Library
Once I've wrote a simple routing library. You know, the one that you can use to make pretty urls such as: http://ferdianto.com/2009/05/21/this-is-a-post. Actually, framework like CodeIgniter has internal support for friendly URLs. But, what if you already have an up-and-running application and decide to make pretty urls. This library is intentionally made simple so that it can be included in any framework or application you have.
The library is inspired by Django — web framework build in python language. So, you only have to specify the URL pattern (perl-compatible-regex) and handler. Here's some simple usage:
include 'route.php';
//a simple controller class
class HelloController
{
function hello()
{
echo 'Hello World';
}
}
//a simple controller class
class TestController
{
function test()
{
echo 'test';
}
}
//a simple controller function
function index()
{
echo 'Hello World';
}
//a simple controller which accept parameters
function testparam()
{
echo '',print_r( func_get_args() ),'
';
}
$urls = array(
//simple function
'!^$!' => 'index',
//using string as classname
'!^test/$!' => array( 'TestController', 'test' ),
//using object
'!^hello/$!' => array( new HelloController, 'hello' ),
//use parameterized regex
'!^archives/(\d+)/(\d+)/(\d+)/(.+)$!' => 'testparam',
//simple include
'!^about$!' => 'about.php',
);
route($urls);
Requirement for this library to work is mod_rewrite. And the configuration is pretty simple, I've just use the wordpress .htaccess configuration. Here's the rewrite syntax:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php [L]
Interested? You can download the source via link below.
http://beta.ferdianto.com/media/route.php
If we have an up and running web already, then we can restructure and redesign the web to have friendly URLs.
That is new project, I think.
And new income.
sweet! so thats how it works :p
lets make it as simple as possible bro
In Home Drug Testinh http://www.online-thecatsmeow.com/ - diflucan
<a href=http://www.online-thecatsmeow.com/>diflucan for men</a> Some of the side effects which are commonly associated with the use of Diflucan include: rash, or skin irritation; headache; dizziness; nausea; vomiting; abdominal pain; diarrhea; and possibly elevated liver enzymes. http://www.online-thecatsmeow.com/ - purchase diflucan Difulcan is a medication which is used in the treatment, and prevention, of fungal infections. http://www.online-thecatsmeow.com/ - fluconazole tablets Unlike other medications on the market, if you miss dose of Diflucan, you will not want to try and catch up by taking an extra dose or two.
Steroid The Drug http://salonevevb.com/ - cialis medication Cialis is preferred by many men because it has a 36 hour window of effectiveness, meaning it doesn?t need to be taken daily for it to be effective. <a href=http://salonevevb.com/>tadalafil online</a>
Hello! cefabde interesting cefabde site! I'm really like it! Very, very cefabde good!
Hello! fekedke interesting fekedke site! I'm really like it! Very, very fekedke good!
Very nice site! <a href="http://apxyieo.com/qyoarx/1.html">cheap viagra</a>
Hello!
Aloha!
Hello!
Hello!
Hello!
Aloha!
Aloha!
Hello!
Aloha!
Hello!
Hello!
Perfect!
Hi there!
Hi there!
Good site,
Aloha!
Good site,
Good site,
Hi there!
Good site,
Aloha!
Hello!
Aloha!