|
| 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