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
d3810642
Commit
d3810642
authored
Jan 13, 2011
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update to the new routing syntax
parent
82a57978
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
7 deletions
+10
-7
README.md
README.md
+2
-2
src/Silex/Framework.php
src/Silex/Framework.php
+4
-1
src/vendor/symfony
src/vendor/symfony
+1
-1
tests/Silex/Tests/RouterTest.php
tests/Silex/Tests/RouterTest.php
+3
-3
No files found.
README.md
View file @
d3810642
...
@@ -8,11 +8,11 @@ Silex is a simple web framework to develop simple websites:
...
@@ -8,11 +8,11 @@ Silex is a simple web framework to develop simple websites:
$app = Framework::create();
$app = Framework::create();
$app->get('/home/
:name
', function($name) {
$app->get('/home/
{name}
', function($name) {
return "Hello $name";
return "Hello $name";
});
});
$app->match('/goodbye/
:name
', function($name) {
$app->match('/goodbye/
{name}
', function($name) {
return "Goodbye $name";
return "Goodbye $name";
});
});
...
...
src/Silex/Framework.php
View file @
d3810642
...
@@ -79,8 +79,11 @@ class Framework extends HttpKernel
...
@@ -79,8 +79,11 @@ class Framework extends HttpKernel
$requirements
[
'_method'
]
=
$method
;
$requirements
[
'_method'
]
=
$method
;
}
}
$routeName
=
(
string
)
$method
.
$pattern
;
$routeName
=
str_replace
(
array
(
'{'
,
'}'
),
''
,
$routeName
);
$routeName
=
str_replace
(
array
(
'/'
,
':'
,
'|'
),
'_'
,
$routeName
);
$route
=
new
Route
(
$pattern
,
array
(
'_controller'
=>
$to
),
$requirements
);
$route
=
new
Route
(
$pattern
,
array
(
'_controller'
=>
$to
),
$requirements
);
$this
->
routes
->
add
(
str_replace
(
array
(
'/'
,
':'
,
'|'
),
'_'
,
(
string
)
$method
.
$pattern
)
,
$route
);
$this
->
routes
->
add
(
$routeName
,
$route
);
return
$this
;
return
$this
;
}
}
...
...
symfony
@
36d87d94
Subproject commit
183acd8460e048d8bbd1aae56e58846712014505
Subproject commit
36d87d94648e11b52ad55f82ec781aa01bd16ca9
tests/Silex/Tests/RouterTest.php
View file @
d3810642
...
@@ -93,13 +93,13 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -93,13 +93,13 @@ class RouterTest extends \PHPUnit_Framework_TestCase
'/hello'
=>
function
()
{
'/hello'
=>
function
()
{
return
"Hello anon"
;
return
"Hello anon"
;
},
},
'/hello/
:name
'
=>
function
(
$name
)
{
'/hello/
{name}
'
=>
function
(
$name
)
{
return
"Hello
$name
"
;
return
"Hello
$name
"
;
},
},
'/goodbye/
:name
'
=>
function
(
$name
)
{
'/goodbye/
{name}
'
=>
function
(
$name
)
{
return
"Goodbye
$name
"
;
return
"Goodbye
$name
"
;
},
},
'/tell/
:name/:message
'
=>
function
(
$message
,
$name
)
{
'/tell/
{name}/{message}
'
=>
function
(
$message
,
$name
)
{
return
"Message for
$name
:
$message
"
;
return
"Message for
$name
:
$message
"
;
},
},
'/'
=>
function
()
{
'/'
=>
function
()
{
...
...
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