Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
c621e23a
Commit
c621e23a
authored
Sep 17, 2010
by
Kris Wallsmith
Committed by
Fabien Potencier
Sep 18, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for RESTful routes.
parent
ab1f17b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
example.php
example.php
+12
-2
silex.phar
silex.phar
+0
-0
src/Silex/Framework.php
src/Silex/Framework.php
+7
-1
No files found.
example.php
View file @
c621e23a
...
...
@@ -11,12 +11,22 @@ $hello = function ($name)
return
new
Response
(
'Hello '
.
$name
);
};
$goodbye
=
function
(
$name
)
{
return
new
Response
(
'Goodbye '
.
$name
);
};
$framework
=
new
Framework
(
array
(
'/hello/:name'
=>
$hello
,
'GET /hello/:name'
=>
$hello
,
'POST /goodbye/:name'
=>
$goodbye
,
));
// Simulate a request without a Client
// Simulate a
hello
request without a Client
//$request = Request::create('/hello/Fabien');
//$framework->handle($request)->send();
// Simulate a goodbye request without a Client
//$request = Request::create('/goodbye/Fabien', 'post');
//$framework->handle($request)->send();
$framework
->
handle
()
->
send
();
silex.phar
View file @
c621e23a
No preview for this file type
src/Silex/Framework.php
View file @
c621e23a
...
...
@@ -32,7 +32,13 @@ class Framework extends HttpKernel
{
$this
->
routes
=
new
RouteCollection
();
foreach
(
$map
as
$pattern
=>
$to
)
{
$route
=
new
Route
(
$pattern
,
array
(
'_controller'
=>
$to
));
if
(
false
!==
strpos
(
$pattern
,
' '
))
{
list
(
$method
,
$pattern
)
=
explode
(
' '
,
$pattern
,
2
);
}
else
{
$method
=
'GET'
;
}
$route
=
new
Route
(
$pattern
,
array
(
'_controller'
=>
$to
),
array
(
'_method'
=>
explode
(
'|'
,
$method
)));
$this
->
routes
->
addRoute
(
str_replace
(
array
(
'/'
,
':'
),
'_'
,
$pattern
),
$route
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment