Skip to content

Instantly share code, notes, and snippets.

View cnevinc's full-sized avatar

Nevin cnevinc

View GitHub Profile
d:
cd D:\DEV\Google\
"google_appengine\dev_appserver.py" HelloGAEProject/
<?php
echo 'Hello, World!';
?>
application: helloworld
version: 1
runtime: php
api_version: 1
handlers:
- url: /.*
script: helloworld.php
<?php
require_once 'google/appengine/api/users/UserService.php';
use google\appengine\api\users\User;
use google\appengine\api\users\UserService;
$user = UserService::getCurrentUser(); // 如果使用者已經登入,此處的$user不為null
if ($user===null) {
header('Location: ' . // 如果未登入,將使用者導向登入頁面,
application: helloworld
version: 1
runtime: php
api_version: 1
handlers:
- url: /stylesheets #當GAE收到http request帶有"stylesheets"字樣的URL時
static_dir: stylesheets #,會去"stylesheets"這個資料夾找相對應的資源顯示給使用者
- url: /.* #除此之外,其他的request
<head>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
</head>
// Production on Google Cloud SQL
$db = new PDO('mysql:unix_socket=/cloudsql/regal-center-453:guestbook;dbname=guestbook;charset=utf8','root', ''); // 不用指定密碼因為已經給該project/application權限
// Development on Local Machine
$db = new PDO('mysql:host=localhost;dbname=guestbook'); // 我沒指定帳號密碼因為我GRANT ALL ON *.* to '@locahost'
"google_appengine/appcfg.py" update HelloGAEProject
<?php
require_once 'google/appengine/api/users/UserService.php';
use google\appengine\api\users\User;
use google\appengine\api\users\UserService;
$user = UserService::getCurrentUser(); // 如果使用者已經登入,此處的$user不為null
if ($user===null) {
header('Location: ' . // 如果未登入,將使用者導向登入頁面,
CREATE DATABASE `guestbook` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `guestbook`;
CREATE TABLE `message` (
`id` int(10) NOT NULL auto_increment,
`message` text NOT NULL,
`user` varchar(50) NOT NULL,
PRIMARY KEY (`id`)