File tree Expand file tree Collapse file tree 8 files changed +1276
-498
lines changed
Expand file tree Collapse file tree 8 files changed +1276
-498
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright 2015 Google Inc.
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ */
17+
18+ // Install composer dependencies with "composer install"
19+ // @see http://getcomposer.org for more information.
20+ require __DIR__ . '/vendor/autoload.php ' ;
21+
22+ $ app = require __DIR__ . '/app.php ' ;
23+
24+ /** @var PDO $db */
25+ $ db = $ app ['database ' ];
26+
27+ # [START create_tables]
28+ // create the tables
29+ $ stmt = $ db ->prepare ('CREATE TABLE entries (
30+ entryID INT NOT NULL AUTO_INCREMENT,
31+ guestName VARCHAR(255),
32+ content VARCHAR(255),
33+ PRIMARY KEY(entryID)
34+ ) ' );
35+
36+ $ result = $ stmt ->execute ();
37+ # [END create_tables]
38+
39+ if (false === $ result ) {
40+ printf ("Error: %s \n" , $ stmt ->errorInfo ()[2 ]);
41+ } else {
42+ printf ('Tables created ' );
43+ }
Original file line number Diff line number Diff line change 1515 * limitations under the License.
1616 */
1717
18- # [START get_current_user]
19- use google \appengine \api \users \User ;
18+ # [START import]
2019use google \appengine \api \users \UserService ;
20+ # [END import]
2121use Silex \Application ;
2222
2323// create the Silex application
2424$ app = new Application ();
2525
2626$ app ->get ('/ ' , function () use ($ app ) {
27+ # [START get_current_user]
2728 $ user = UserService::getCurrentUser ();
2829
2930 if (isset ($ user )) {
3435 return sprintf ('<a href="%s">Sign in or register</a> ' ,
3536 UserService::createLoginUrl ('/ ' ));
3637 }
38+ # [END get_current_user]
3739});
38- # [END get_current_user]
3940
4041return $ app ;
Original file line number Diff line number Diff line change 11{
22 "require" : {
3- "silex/silex" : " ^1.3" ,
4- "php-http/guzzle6-adapter" : " ^1.0" ,
5- "google/apiclient" : " ^1.1"
3+ "silex/silex" : " ^1.3"
64 },
75 "require-dev" : {
6+ "phpunit/phpunit" : " ~4" ,
7+ "guzzlehttp/guzzle" : " ~6.0" ,
88 "symfony/browser-kit" : " ^3.0"
99 }
1010}
You can’t perform that action at this time.
0 commit comments