Skip to content

Commit 07b0dfc

Browse files
committed
Adding HttpFoundation and the start of Aura Router
1 parent 0ce63f0 commit 07b0dfc

File tree

3 files changed

+269
-1
lines changed

3 files changed

+269
-1
lines changed

_tuts/aura-router.diff

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
diff --git a/composer.json b/composer.json
2+
index 9577edb..52e5602 100644
3+
--- a/composer.json
4+
+++ b/composer.json
5+
@@ -1,5 +1,6 @@
6+
{
7+
"require": {
8+
- "symfony/http-foundation": "~2.5"
9+
+ "symfony/http-foundation": "~2.5",
10+
+ "aura/router": "~2.1"
11+
}
12+
}
13+
diff --git a/composer.lock b/composer.lock
14+
index 0c27e0c..aee9a74 100644
15+
--- a/composer.lock
16+
+++ b/composer.lock
17+
@@ -4,9 +4,63 @@
18+
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
19+
"This file is @generated automatically"
20+
],
21+
- "hash": "b00ccdf52f1019a5488e57d76eaf5eec",
22+
+ "hash": "05160fed37a43d33fa4fa22bcc76836f",
23+
"packages": [
24+
{
25+
+ "name": "aura/router",
26+
+ "version": "2.1.1",
27+
+ "source": {
28+
+ "type": "git",
29+
+ "url": "https://github.com/auraphp/Aura.Router.git",
30+
+ "reference": "23056b104816f495f4f9f88fc6e7d325671c3bc6"
31+
+ },
32+
+ "dist": {
33+
+ "type": "zip",
34+
+ "url": "https://api.github.com/repos/auraphp/Aura.Router/zipball/23056b104816f495f4f9f88fc6e7d325671c3bc6",
35+
+ "reference": "23056b104816f495f4f9f88fc6e7d325671c3bc6",
36+
+ "shasum": ""
37+
+ },
38+
+ "require": {
39+
+ "php": ">=5.3.0"
40+
+ },
41+
+ "type": "library",
42+
+ "extra": {
43+
+ "aura": {
44+
+ "type": "library",
45+
+ "config": {
46+
+ "common": "Aura\\Router\\_Config\\Common"
47+
+ }
48+
+ },
49+
+ "branch-alias": {
50+
+ "dev-develop-2": "2.0.x-dev"
51+
+ }
52+
+ },
53+
+ "autoload": {
54+
+ "psr-4": {
55+
+ "Aura\\Router\\": "src/",
56+
+ "Aura\\Router\\_Config\\": "config/"
57+
+ }
58+
+ },
59+
+ "notification-url": "https://packagist.org/downloads/",
60+
+ "license": [
61+
+ "BSD-2-Clause"
62+
+ ],
63+
+ "authors": [
64+
+ {
65+
+ "name": "Aura.Router Contributors",
66+
+ "homepage": "https://github.com/auraphp/Aura.Router/contributors"
67+
+ }
68+
+ ],
69+
+ "description": "A web router implementation; given a URI path and a copy of $_SERVER, it will extract path-info parameter values for a specific route.",
70+
+ "homepage": "https://github.com/auraphp/Aura.Router",
71+
+ "keywords": [
72+
+ "route",
73+
+ "router",
74+
+ "routing"
75+
+ ],
76+
+ "time": "2014-10-22 14:14:56"
77+
+ },
78+
+ {
79+
"name": "symfony/http-foundation",
80+
"version": "v2.5.6",
81+
"target-dir": "Symfony/Component/HttpFoundation",

_tuts/steps.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
"id": "start",
55
"name": "start",
66
"description": null
7+
},
8+
{
9+
"id": "symfony-httpfoundation",
10+
"name": "Symfony: HttpFoundation",
11+
"description": null
12+
},
13+
{
14+
"id": "aura-router",
15+
"name": "Aura: Router",
16+
"description": null
717
}
818
],
9-
"sha": "5e466719751ccc1c99724fd61865ab6611c8a262"
19+
"sha": "0ce63f01166eda74f7c74511bf08726bf8dacf67"
1020
}

_tuts/symfony-httpfoundation.diff

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
diff --git a/.gitignore b/.gitignore
2+
index bc46846..58a8864 100644
3+
--- a/.gitignore
4+
+++ b/.gitignore
5+
@@ -1 +1,2 @@
6+
/data/database.sqlite
7+
+/vendor
8+
diff --git a/bootstrap.php b/bootstrap.php
9+
new file mode 100644
10+
index 0000000..52faebf
11+
--- /dev/null
12+
+++ b/bootstrap.php
13+
@@ -0,0 +1,4 @@
14+
+<?php
15+
+
16+
+require __DIR__.'/vendor/autoload.php';
17+
+
18+
diff --git a/composer.json b/composer.json
19+
new file mode 100644
20+
index 0000000..9577edb
21+
--- /dev/null
22+
+++ b/composer.json
23+
@@ -0,0 +1,5 @@
24+
+{
25+
+ "require": {
26+
+ "symfony/http-foundation": "~2.5"
27+
+ }
28+
+}
29+
diff --git a/composer.lock b/composer.lock
30+
new file mode 100644
31+
index 0000000..0c27e0c
32+
--- /dev/null
33+
+++ b/composer.lock
34+
@@ -0,0 +1,70 @@
35+
+{
36+
+ "_readme": [
37+
+ "This file locks the dependencies of your project to a known state",
38+
+ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
39+
+ "This file is @generated automatically"
40+
+ ],
41+
+ "hash": "b00ccdf52f1019a5488e57d76eaf5eec",
42+
+ "packages": [
43+
+ {
44+
+ "name": "symfony/http-foundation",
45+
+ "version": "v2.5.6",
46+
+ "target-dir": "Symfony/Component/HttpFoundation",
47+
+ "source": {
48+
+ "type": "git",
49+
+ "url": "https://github.com/symfony/HttpFoundation.git",
50+
+ "reference": "56111fc8ba8bcad93d367532babecc6ce17f66ce"
51+
+ },
52+
+ "dist": {
53+
+ "type": "zip",
54+
+ "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/56111fc8ba8bcad93d367532babecc6ce17f66ce",
55+
+ "reference": "56111fc8ba8bcad93d367532babecc6ce17f66ce",
56+
+ "shasum": ""
57+
+ },
58+
+ "require": {
59+
+ "php": ">=5.3.3"
60+
+ },
61+
+ "require-dev": {
62+
+ "symfony/expression-language": "~2.4"
63+
+ },
64+
+ "type": "library",
65+
+ "extra": {
66+
+ "branch-alias": {
67+
+ "dev-master": "2.5-dev"
68+
+ }
69+
+ },
70+
+ "autoload": {
71+
+ "psr-0": {
72+
+ "Symfony\\Component\\HttpFoundation\\": ""
73+
+ },
74+
+ "classmap": [
75+
+ "Symfony/Component/HttpFoundation/Resources/stubs"
76+
+ ]
77+
+ },
78+
+ "notification-url": "https://packagist.org/downloads/",
79+
+ "license": [
80+
+ "MIT"
81+
+ ],
82+
+ "authors": [
83+
+ {
84+
+ "name": "Symfony Community",
85+
+ "homepage": "http://symfony.com/contributors"
86+
+ },
87+
+ {
88+
+ "name": "Fabien Potencier",
89+
+ "email": "fabien@symfony.com"
90+
+ }
91+
+ ],
92+
+ "description": "Symfony HttpFoundation Component",
93+
+ "homepage": "http://symfony.com",
94+
+ "time": "2014-10-24 05:49:22"
95+
+ }
96+
+ ],
97+
+ "packages-dev": [],
98+
+ "aliases": [],
99+
+ "minimum-stability": "stable",
100+
+ "stability-flags": [],
101+
+ "prefer-stable": false,
102+
+ "platform": [],
103+
+ "platform-dev": []
104+
+}
105+
diff --git a/index.php b/index.php
106+
index a2b3c5d..ed2564e 100644
107+
--- a/index.php
108+
+++ b/index.php
109+
@@ -1,4 +1,5 @@
110+
<?php
111+
+require __DIR__.'/bootstrap.php';
112+
113+
try {
114+
$dbPath = __DIR__.'/data/database.sqlite';
115+
@@ -7,36 +8,46 @@ try {
116+
die('Panic! '.$e->getMessage());
117+
}
118+
119+
-$uri = $_SERVER['REQUEST_URI'];
120+
-if ($pos = strpos($uri, '?')) {
121+
- $uri = substr($uri, 0, $pos);
122+
-}
123+
+// create a request object to help us
124+
+use Symfony\Component\HttpFoundation\Request;
125+
+use Symfony\Component\HttpFoundation\Response;
126+
+$request = Request::createFromGlobals();
127+
+
128+
+$uri = $request->getPathInfo();
129+
130+
if ($uri == '/' || $uri == '') {
131+
132+
- echo '<h1>PHP Camp!</h1>';
133+
- echo '<a href="/attendees">See the attendees</a>';
134+
- if (isset($_GET['name'])) {
135+
- echo sprintf('<p>Oh, and hello %s!</p>', $_GET['name']);
136+
+ $content = '<h1>PHP Camp!</h1>';
137+
+ $content .= '<a href="/attendees">See the attendees</a>';
138+
+ if ($name = $request->query->get('name')) {
139+
+ $content .= sprintf('<p>Oh, and hello %s!</p>', $name);
140+
}
141+
142+
+ $response = new Response($content);
143+
+
144+
} elseif ($uri == '/attendees') {
145+
146+
$sql = 'SELECT * FROM php_camp';
147+
- echo '<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />';
148+
- echo '<h1>PHP Camp Attendees</h1>';
149+
- echo '<table class="table" style="width: 300px;">';
150+
+ $content = '<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />';
151+
+ $content .= '<h1>PHP Camp Attendees</h1>';
152+
+ $content .= '<table class="table" style="width: 300px;">';
153+
foreach ($dbh->query($sql) as $row) {
154+
- echo sprintf(
155+
+ $content .= sprintf(
156+
'<tr><td style="font-size: 24px;">%s</td><td><img src="%s" height="120" /></td></tr>',
157+
$row['attendee'],
158+
$row['avatar_url']
159+
);
160+
}
161+
- echo '</table>';
162+
+ $content .= '</table>';
163+
+
164+
+ $response = new Response($content);
165+
166+
} else {
167+
- header("HTTP/1.1 404 Not Found");
168+
- echo '<h1>404 Page not Found</h1>';
169+
- echo '<p>Find a boy (or girl) scout - they can fix this!</p>';
170+
+ $content = '<h1>404 Page not Found</h1>';
171+
+ $content .= '<p>Find a boy (or girl) scout - they can fix this!</p>';
172+
+
173+
+ $response = new Response($content);
174+
+ $response->setStatusCode(404);
175+
}
176+
+
177+
+$response->send();

0 commit comments

Comments
 (0)