Skip to content

Commit e2cf3cf

Browse files
committed
Removing some dead code��:wq
1 parent e251e17 commit e2cf3cf

File tree

4 files changed

+45
-43
lines changed

4 files changed

+45
-43
lines changed

_tuts/pimple-dic.diff

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,31 @@ index aee9a74..9642f7c 100644
7878
"version": "v2.5.6",
7979
"target-dir": "Symfony/Component/HttpFoundation",
8080
diff --git a/index.php b/index.php
81-
index d8c644d..7c5d9af 100644
81+
index d8c644d..646ee16 100644
8282
--- a/index.php
8383
+++ b/index.php
84-
@@ -12,30 +12,52 @@ try {
84+
@@ -1,41 +1,56 @@
85+
<?php
86+
require __DIR__.'/bootstrap.php';
87+
88+
-try {
89+
- $dbPath = __DIR__.'/data/database.sqlite';
90+
- $dbh = new PDO('sqlite:'.$dbPath);
91+
-} catch(PDOException $e) {
92+
- die('Panic! '.$e->getMessage());
93+
-}
94+
-
95+
// create a request object to help us
8596
use Symfony\Component\HttpFoundation\Request;
8697
use Symfony\Component\HttpFoundation\Response;
8798
use Aura\Router\RouterFactory;
8899
+use Pimple\Container;
89-
90-
-$request = Request::createFromGlobals();
91-
-$uri = $request->getPathInfo();
100+
+
92101
+$c = new Container();
93-
94-
-$routerFactory = new RouterFactory();
95-
-$router = $routerFactory->newInstance();
102+
+
96103
+// configuration
97104
+$c['connection_string'] = 'sqlite:'.__DIR__.'/data/database.sqlite';
98-
99-
-// create a router, build the routes, and then execute it
100-
-$router->add('attendees_list', '/attendees')
101-
- ->addValues(['controller' => 'attendees_controller']);
102-
-$router->add('homepage', '{/name}')
103-
- ->addValues(['controller' => 'homepage_controller']);
104-
-$route = $router->match($uri, $request->server->all());
105+
+
105106
+// Service setup
106107
+$c['connection'] = function(Container $c) {
107108
+ return new PDO($c['connection_string']);
@@ -115,16 +116,26 @@ index d8c644d..7c5d9af 100644
115116
+ $routerFactory = new RouterFactory();
116117
+
117118
+ $router = $routerFactory->newInstance();
118-
+
119+
120+
-$request = Request::createFromGlobals();
121+
-$uri = $request->getPathInfo();
119122
+ // create a router, build the routes, and then execute it
120123
+ $router->add('attendees_list', '/attendees')
121124
+ ->addValues(['controller' => 'attendees_controller']);
122125
+ $router->add('homepage', '{/name}')
123126
+ ->addValues(['controller' => 'homepage_controller']);
124-
+
127+
128+
-$routerFactory = new RouterFactory();
129+
-$router = $routerFactory->newInstance();
125130
+ return $router;
126131
+};
127-
+
132+
133+
-// create a router, build the routes, and then execute it
134+
-$router->add('attendees_list', '/attendees')
135+
- ->addValues(['controller' => 'attendees_controller']);
136+
-$router->add('homepage', '{/name}')
137+
- ->addValues(['controller' => 'homepage_controller']);
138+
-$route = $router->match($uri, $request->server->all());
128139
+// run the framework!
129140
+$route = $c['router']->match(
130141
+ $c['request']->getPathInfo(),
@@ -147,7 +158,7 @@ index d8c644d..7c5d9af 100644
147158
if (!$response instanceof Response) {
148159
throw new Exception(sprintf('Your controller "%s" did not return a response!!', $controller));
149160
}
150-
@@ -56,8 +78,8 @@ function homepage_controller(Request $request) {
161+
@@ -56,8 +71,8 @@ function homepage_controller(Request $request) {
151162
return new Response($content);
152163
}
153164

_tuts/reorganization.diff

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,13 @@ index 0000000..9adb562
147147
+ return $response;
148148
+}
149149
diff --git a/index.php b/index.php
150-
index 5f42f7a..15a2099 100644
150+
index 919eee1..dd22794 100644
151151
--- a/index.php
152152
+++ b/index.php
153-
@@ -1,128 +1,7 @@
153+
@@ -1,121 +1,8 @@
154154
<?php
155155
-require __DIR__.'/bootstrap.php';
156-
-
157-
-try {
158-
- $dbPath = __DIR__.'/data/database.sqlite';
159-
- $dbh = new PDO('sqlite:'.$dbPath);
160-
-} catch(PDOException $e) {
161-
- die('Panic! '.$e->getMessage());
162-
-}
163-
-
156+
164157
-// create a request object to help us
165158
-use Symfony\Component\HttpFoundation\Request;
166159
-use Symfony\Component\HttpFoundation\Response;
@@ -233,8 +226,12 @@ index 5f42f7a..15a2099 100644
233226
-if (!$response instanceof Response) {
234227
- throw new Exception(sprintf('Your controller "%s" did not return a response!!', $controller));
235228
-}
236-
-
237-
-$response->send();
229+
+$c = require __DIR__.'/bootstrap.php';
230+
+require 'routing.php';
231+
+require 'controllers.php';
232+
233+
+$response = _run_app($c);
234+
$response->send();
238235
-
239236
-/*
240237
- * My Controllers!
@@ -278,13 +275,7 @@ index 5f42f7a..15a2099 100644
278275
-
279276
- return $response;
280277
-}
281-
+$c = require __DIR__.'/bootstrap.php';
282-
+require 'routing.php';
283-
+require 'controllers.php';
284-
285-
+$response = _run_app($c);
286-
+$response->send();
287-
\ No newline at end of file
278+
-
288279
diff --git a/routing.php b/routing.php
289280
new file mode 100644
290281
index 0000000..2b48429

_tuts/steps.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
"description": null
3232
}
3333
],
34-
"sha": "bc624c5e8ca0fb8126e120712a21560498b7a882"
34+
"sha": "e251e17cf10ac544e14cfa93d6ec4bceb05dcef9"
3535
}

_tuts/zf-logger.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ index 9642f7c..5dfd2c3 100644
198198
],
199199
"packages-dev": [],
200200
diff --git a/index.php b/index.php
201-
index 7c5d9af..5f42f7a 100644
201+
index 646ee16..919eee1 100644
202202
--- a/index.php
203203
+++ b/index.php
204-
@@ -13,11 +13,14 @@ use Symfony\Component\HttpFoundation\Request;
204+
@@ -6,11 +6,14 @@ use Symfony\Component\HttpFoundation\Request;
205205
use Symfony\Component\HttpFoundation\Response;
206206
use Aura\Router\RouterFactory;
207207
use Pimple\Container;
@@ -216,7 +216,7 @@ index 7c5d9af..5f42f7a 100644
216216

217217
// Service setup
218218
$c['connection'] = function(Container $c) {
219-
@@ -41,6 +44,15 @@ $c['router'] = function() {
219+
@@ -34,6 +37,15 @@ $c['router'] = function() {
220220

221221
return $router;
222222
};
@@ -232,7 +232,7 @@ index 7c5d9af..5f42f7a 100644
232232

233233
// run the framework!
234234
$route = $c['router']->match(
235-
@@ -56,6 +68,13 @@ if ($route) {
235+
@@ -49,6 +61,13 @@ if ($route) {
236236
// get the "controller" out, or default to error404_controller
237237
$controller = $c['request']->attributes->get('controller', 'error404_controller');
238238

0 commit comments

Comments
 (0)