ObjectOrientedURLs
Posted: Sun Sep 20, 2009 7:02 pm
I had a couple of annoyances when writing object oriented websites.
The first was lots of php files that did little more that instantiate my class. Having all these little files all over the web server seemed like an awful lot of clutter, and unnecessary.
The second was using mod-rewrite to create friendly URLs. Whenever I made a new friendly URL, I had to go in and edit the rewrite rules & restart the web server. So I wrote ObjectOrientedURLs
ObjectOrientedURLs lets you call class methods directly from URLs, without having to upload a PHP file that instantiates your class and calls the method. All you need to to is write method names that match up to the URLs on your website. To make a new page, all you need to do is write the class method and upload your class to the server.
I'd love to get a few eyeballs on the code, and some feedback.
You can check out the code and download the class, along with the .htaccess file, below.
http://www.davecomeau.net/blog/17/PHP+C ... ientedURLs
The first was lots of php files that did little more that instantiate my class. Having all these little files all over the web server seemed like an awful lot of clutter, and unnecessary.
The second was using mod-rewrite to create friendly URLs. Whenever I made a new friendly URL, I had to go in and edit the rewrite rules & restart the web server. So I wrote ObjectOrientedURLs
ObjectOrientedURLs lets you call class methods directly from URLs, without having to upload a PHP file that instantiates your class and calls the method. All you need to to is write method names that match up to the URLs on your website. To make a new page, all you need to do is write the class method and upload your class to the server.
I'd love to get a few eyeballs on the code, and some feedback.
You can check out the code and download the class, along with the .htaccess file, below.
http://www.davecomeau.net/blog/17/PHP+C ... ientedURLs