Skip to content

Commit 157834a

Browse files
authored
Update readme.md
1 parent 8ef1e60 commit 157834a

File tree

1 file changed

+158
-7
lines changed

1 file changed

+158
-7
lines changed

README.md

Lines changed: 158 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
# php-route
1+
# DRIM PHP Route
22

33
Simple PHP Fast Routing for Small Web Application or Rest API .
44

5+
**DRIM** is the abbreviation of **D**ispite **R**edicule **I**t's **M**ade . Basically its being published as an open source PHP Micro Framework . As far now, I'm publishing it's basic routing system .
6+
7+
8+
59
### Features
610

711
1. Easy Deployment
812
2. Fastest Routing
913
3. Parameter Supports
1014
4. Request Handlier [GET, POST, PUT, DELETE, ANY]
11-
5. Controller Forwarding
12-
6. Redirecting
15+
5. Redirecting
16+
6. Controller Forwarding
1317

1418

1519

1620
### User Guide
1721

18-
###### Route Structures
22+
How to use DRIM PHP Route
23+
24+
##### Understanding Route Structures
1925

2026
`Route::METHOD(ROUTE, CALLBACK);`
2127

@@ -25,19 +31,164 @@ That means, a route should be like
2531

2632
```php
2733
Route::get("/", function(){
34+
echo "This is home page";
35+
});
36+
```
37+
38+
```php
39+
Route::get("/contact", function(){
40+
echo "This is contact page";
41+
});
42+
```
43+
44+
##### Using Parameter
45+
46+
You can use parameters . Follow this structure .
47+
48+
49+
50+
```php
51+
Route::get("/user/{id}", function($id){
52+
echo "This is user number " . $id;
53+
});
54+
```
55+
56+
or
57+
58+
```php
59+
Route::get("/name/:myname", function($someName){
60+
echo "My name is " . $someName;
61+
});
62+
```
2863

29-
echo "This is home page";
64+
Muliple Parameter shoule be like this
3065

66+
```php
67+
Route::get("/post/{user}/{post}", function($user, $post){
68+
echo "Show the post number " . $post . " of " . $user . " user";
3169
});
3270
```
3371

72+
73+
74+
##### Request Method
75+
76+
It supports request handling .
77+
78+
like if you are thinking to apply post method, just use method post for `Route::post();`
79+
3480
```php
35-
Route::get("contact", function(){
81+
Route::post("/about/", function(){
82+
echo "About Page";
83+
});
84+
```
85+
86+
87+
88+
You can use 6 different method . The list is bellow
89+
90+
1. GET
91+
2. POST
92+
3. PUT
93+
4. DELETE
94+
5. ANY
3695

37-
echo "This is contact page";
96+
**any** method is basically cross of all method .
3897

98+
99+
100+
Examples:
101+
102+
```php
103+
Route::get("/about/", function(){
104+
echo "About Page, only get request allow";
39105
});
40106

107+
Route::post("/about/", function(){
108+
echo "About Page, only post request allow";
109+
});
41110

111+
Route::put("/about/", function(){
112+
echo "About Page, only post put allow";
113+
});
114+
115+
Route::delete("/about/", function(){
116+
echo "About Page, only post delete allow";
117+
});
118+
119+
Route::any("/about/", function(){
120+
echo "About Page, all available requests are allowed";
121+
});
42122
```
43123

124+
125+
126+
127+
128+
##### Directing
129+
130+
You can redirect any url to another .
131+
132+
Internal usage
133+
134+
```php
135+
Route::redirect('/here', '/there');
136+
```
137+
138+
External usage
139+
140+
```php
141+
Route::redirect('/jafran', 'https://www.facebook.com/iamjafran');
142+
```
143+
144+
145+
146+
##### Controller Forwarding
147+
148+
You can easily navigate your request to controller class .
149+
150+
```php
151+
Route::get('/test', 'yourController@test');
152+
```
153+
154+
Here, `yourController` is a class in your controller folder and `test` is a method of this class .
155+
156+
You can just forward your controller to `__construct` method by justing not mentioning any method name .
157+
158+
Easy!
159+
160+
```php
161+
Route::get('/test', 'yourController');
162+
```
163+
164+
165+
166+
167+
168+
### .htaccess
169+
170+
the `.htacccess` file should be like this
171+
172+
```php
173+
RewriteEngine on
174+
RewriteCond %{REQUEST_FILENAME} !-f
175+
RewriteCond %{REQUEST_FILENAME} !-d
176+
RewriteRule ^(.*)$ /index.php [NC,L,QSA]
177+
```
178+
179+
180+
181+
182+
183+
### Contribution
184+
185+
The base developer is [Jafran Hasan](http://facebook.com/iamjafran) . Dhaka Polytechnic Institute .
186+
187+
The core contributors are... [awaiting]
188+
189+
See the websites based on this DRIM Routing System .
190+
191+
www.btebresults.com
192+
193+
My project website : www.returnxero.com
194+

0 commit comments

Comments
 (0)