What is Takhreej?
It is a very simple customizable PHP open source web addresses (URLs) manager and router, suitable for simple websites.
User Guide:
All you have to do is to
download the source code, and save it in your web root. Takhreej supposes that your web pages are stored under the folder named
pages which is stored under the web root directly (you can change it by modifying the line 77 in the source code), also, Takhreej supposes that you are using unified layout for all the pages (header & footer) which are stored under the folder named
layout which is stored under the web root directly (you can change it or disable it by modifying or removing the lines 75 & 79 in the source code).
In case you used Takhreej as it is, your directory tree might look like this *:
root
│
├── index.php
│
├── layout
│   │
│   ├── header.php
│   └── footer.php
│
└── pages
    │
    ├── home.php
    ├── 404.php
    ├── about.php
    ├── contact.php
    │
    └── thread
        │
        ├── add.php
        ├── view.php
        └── index.php
Simply, if you request
yoursite.com then the file
home.php will be rendered, and if you request
yoursite.com/about then the file
about.php will be rendered, and if you request
yoursite.com/thread/add then the file
add.php will be rendered, and so on, and it worth to mention that the two layouts files (header.php & footer.php) will be rendered with every page unless you disabled or modified them.
* What is in italic is example
Important Note:
Your .htaccess file should have the following lines:
1 | RewriteEngine On |
2 | RewriteCond %{REQUEST_FILENAME} !-f |
3 | RewriteCond %{REQUEST_FILENAME} !-d |
4 | RewriteRule ^/?(.*) index.php [L] |
Download & Development:
Takhreej is a seed for an open source web addresses (URLs) manager and router, it will be developed later on, you can participate in Takhreej's development or downloading it on
GitHub.
Or you can
download it here directly.
Source Code:
| |
| <?php |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| if (!empty($_SERVER['REQUEST_URI'])) |
| { |
|     $root = dirname(__FILE__); |
| |
| |
|     $file_name = $_SERVER['REQUEST_URI']; |
| |
| |
| |
| |
|     if ($file_name == '/index.php' || $file_name == '/') |
|     { |
|         $file_name = 'home'; |
|     } |
|      |
|      |
|      |
|      |
|     switch ($file_name) { |
|         case 'banana': |
|             $title = 'I love banana!'; |
|             $description = 'I love banana!'; |
|             break; |
|         default: |
| |
|             $title = 'My lovely site!'; |
|             $description = 'You will fall in love with my site!'; |
|             break; |
|     } |
| |
| |
| |
|     if (!file_exists($root . '/pages/' . $file_name . '.php')) |
|     { |
|         header('HTTP/1.0 404 Not Found'); |
|         $file_name = '404'; |
|     } |
| |
|      |
|     require_once $root . '/layout/header.php'; |
|      |
|     require_once $root . '/pages/' . $file_name . '.php'; |
|      |
|     require_once $root . '/layout/footer.php'; |
|     exit; |
| } |
| |