-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
77 lines (50 loc) · 2.19 KB
/
README
File metadata and controls
77 lines (50 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
__ __ ____ _ _ ____
\ \ / /_ ___ _____ | _ \| | | | _ \
\ \ /\ / / _` \ \ / / _ \ | |_) | |_| | |_) |
\ V V / (_| |\ V / __/ | __/| _ | __/
\_/\_/ \__,_| \_/ \___| |_| |_| |_|_|
A quick and uncluttered way to setup a structure for routing requests.
Wave can be though of as a mini-toolkit with a autoloader implementation,
it makes structuring multiple libraries/frameworks together an easy task
and allows developers to focus on the business logic rather than trying
to make the tools behave they want.
INSTALL ======================================================
To install, pull this down to your web server
$ git clone https://lafka@github.com/lafka/Wave.git
Create a link of the index file
$ ln -P Wave/index.php .
Add the rewrite rules you need:
# NGINX
if ( !-e $request_filename )
{
rewrite ^/(.*)$ /index.php last;
}
# In your php_fpm call add this:
fastcgi_param WAVE_ENV production
# APACHE
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} \.php$ [OR]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
# Valid is production,stage,dev - if none is set production is assumed
SetEnv WAVE_ENV production
FIRST STEPS ======================================================
Create a new package with some routes:
mkdir -p MyPkg/{Hello,Goodbye}
Create the router for it
touch !$/Route.php
A controller must be in the namespace that corelates to the path, so
your controller would be named \MyPkg\{Hello,Goodbye}\Route. The route
will also need to implement \Wave\Route\Iface. A stripped router would
look something like this (RegEx route is a predefined route which can be
used to match Regexes with the URL):
namespace MyPkg\Hello;
use Wave\Route\Iface as RouteInterface, Wave\Route\Regex as RegexRoute;
class Route extends RegexRoute implements RouteInterface {
{
protected $regex = '~/(?hello|good-?day)~i';
public function dispatch ($uri) {
echo "Good day to you!";
}
}
This matches all request that starts with hello, good-day or goodday.