31
Storing Data http://goo.gl/5KZ3AQ

GAE for PHP - Google Cloud SQL and Cloud Storage

Embed Size (px)

Citation preview

Page 1: GAE for PHP - Google Cloud SQL and Cloud Storage

Storing Data

http://goo.gl/5KZ3AQ

Page 2: GAE for PHP - Google Cloud SQL and Cloud Storage

Storing Data

● Enable Billing

● Using Google Cloud SQL

● Google Cloud Storage

Page 3: GAE for PHP - Google Cloud SQL and Cloud Storage
Page 4: GAE for PHP - Google Cloud SQL and Cloud Storage

Storing Data

● Enable Billing

● Using Google Cloud SQL

● Google Cloud Storage

Page 5: GAE for PHP - Google Cloud SQL and Cloud Storage

Using Google Cloud SQL with App Engine PHP SDK1. Creating a Cloud SQL instance

2. Build a starter application and database

3. Connect to your database

4. Size and access limits

Page 6: GAE for PHP - Google Cloud SQL and Cloud Storage

Creating a Cloud SQL Instance

Page 7: GAE for PHP - Google Cloud SQL and Cloud Storage

Using Google Cloud SQL with App Engine PHP SDK1. Creating a Cloud SQL instance

2. Build a starter application and database

3. Connect to your database

4. Size and access limits

Page 8: GAE for PHP - Google Cloud SQL and Cloud Storage

Build a starter application and database1. Create your App Engine sample application

○ Hello GAE!

2. Grant your App Engine application access to

the Google Cloud SQL instance

3. Create your database and table

Page 9: GAE for PHP - Google Cloud SQL and Cloud Storage

Build a starter application and database1. Create your App Engine sample application

○ Hello GAE!

2. Grant your App Engine application access to

the Google Cloud SQL instance

3. Create your database and table

Page 10: GAE for PHP - Google Cloud SQL and Cloud Storage

Grant your App Engine applicationStep 1

Step 2

Step 3

Page 11: GAE for PHP - Google Cloud SQL and Cloud Storage

Build a starter application and database1. Create your App Engine sample application

○ Hello GAE!

2. Grant your App Engine application access to

the Google Cloud SQL instance

3. Create your database and table

Page 12: GAE for PHP - Google Cloud SQL and Cloud Storage

Create your database and table1. Connecting MySQL

● Use the MySQL command-line tool

● Sequel Pro

2. Create database and table

Page 13: GAE for PHP - Google Cloud SQL and Cloud Storage

Using Google Cloud SQL with App Engine PHP SDK1. Creating a Cloud SQL instance

2. Build a starter application and database

3. Connect to your database

4. Size and access limits

Page 14: GAE for PHP - Google Cloud SQL and Cloud Storage

Connect to your database

1. Using PHP common connection methods

PDO_MySQL, mysqli, MySQL API

2. Test Example (http://goo.gl/b2YkmD)

3. Update your configuration file

4. Deployment!

Page 15: GAE for PHP - Google Cloud SQL and Cloud Storage

Using Google Cloud SQL with App Engine PHP SDK1. Creating a Cloud SQL instance

2. Build a starter application and database

3. Connect to your database

4. Size and access limits

Page 16: GAE for PHP - Google Cloud SQL and Cloud Storage

Size and access limits

60 seconds

HTTP request timer

10 mimutes

Offline requests & Backend requests

Page 17: GAE for PHP - Google Cloud SQL and Cloud Storage

Storing Data

● Enable Billing

● Using Google Cloud SQL

● Google Cloud Storage

Page 18: GAE for PHP - Google Cloud SQL and Cloud Storage

Google Cloud Storage

● Reading and Writing Files

● Publically Accessible Files

● User Uploads

● Serving Images

Page 19: GAE for PHP - Google Cloud SQL and Cloud Storage

Reading and Writing File

Two ways to write files to GSC

1. Write files from your app

● Simple file write

● Streamed file write

2. Let the user upload files to GCS

Page 20: GAE for PHP - Google Cloud SQL and Cloud Storage

Writing files from your app

gs://bucket_name/desired_object_name

You can obtain a default bucket for it by clicking

Create within the Cloud Integration section in

the Application Settings page of the App

Engine Admin Console

Page 21: GAE for PHP - Google Cloud SQL and Cloud Storage

Simple file write

Streamed file write

http://goo.gl/LZESqj

Page 22: GAE for PHP - Google Cloud SQL and Cloud Storage

Google Cloud Storage

● Reading and Writing Files

● Publically Accessible Files

● User Uploads

● Serving Images

Page 23: GAE for PHP - Google Cloud SQL and Cloud Storage

Publically Accessible Files

Create a public-readable file containing some

random numbers, writing it to a GCS bucket,

and redirect to that file form GCS.

Page 24: GAE for PHP - Google Cloud SQL and Cloud Storage

Example

Page 25: GAE for PHP - Google Cloud SQL and Cloud Storage

Google Cloud Storage

● Reading and Writing Files

● Publically Accessible Files

● User Uploads

● Serving Images

Page 26: GAE for PHP - Google Cloud SQL and Cloud Storage

User Uploads

Create the applicaton specific upload URL, using the method

CloudStorageTools::createUploadUrl()You must start uploading to this URL within 10 minutes of its creation.Use this URL as the action for the form you use to accept uploads.

Page 27: GAE for PHP - Google Cloud SQL and Cloud Storage

Example

Page 28: GAE for PHP - Google Cloud SQL and Cloud Storage

Google Cloud Storage

● Reading and Writing Files

● Publically Accessible Files

● User Uploads

● Serving Images

Page 29: GAE for PHP - Google Cloud SQL and Cloud Storage

Serving Images

CloudStorageTools.getImageServingUrl()CloudStorageTools.deleteImageServingUrl()

Page 30: GAE for PHP - Google Cloud SQL and Cloud Storage

My Github example

http://goo.gl/zQkq5U

Page 31: GAE for PHP - Google Cloud SQL and Cloud Storage

http://goo.gl/SNvdxv