In this assignment, your job is to:
Propel
library in that directory with the posting
database we all made togetheruser
records from that databasePOST
new users (username, first_name, last_name, join_date)Note that the examples given to you in the Propel Setup reference show you most of what you need to do. However, there's a lot of details to wrestle with.
The standard setup for your LAMP server serves up websites from the /var/www/html
directory. Follow these steps to setup a website project directory.
etomai@lamp-6312-vm:~$ ls -l total 0 etomai@lamp-6312-vm:~$ mkdir myproject etomai@lamp-6312-vm:~$ ls -l total 4 drwxr-xr-x 3 etomai etomai 4096 Mar 15 14:54 myproject
etomai@lamp-6312-vm:~$ echo "hi" > myproject/test.html etomai@lamp-6312-vm:~$ ls -l myproject total 1 -rw-r--r-- 1 etomai etomai 3 Mar 21 22:53 test.html
/var/www/html
etomai@lamp-6312-vm:~$ ls -l /var/www/html total 16 -rw-r--r-- 1 www-data www-data 10708 Feb 22 01:05 index.html -rw-r--r-- 1 www-data www-data 132 Dec 12 19:14 robots.txt etomai@lamp-6312-vm:~$ sudo ln -s ~/myproject/ /var/www/html/myproject etomai@lamp-6312-vm:~$ ls -l /var/www/html total 16 -rw-r--r-- 1 www-data www-data 10708 Feb 22 01:05 index.html lrwxrwxrwx 1 root root 23 Mar 21 22:53 myproject -> /home/etomai/myproject/ -rw-r--r-- 1 www-data www-data 132 Dec 12 19:14 robots.txt
myproject
directory. Test it by getting the external IP from your GCP Console and browse to http://[IP]/myproject/test.html
You'll submit your project to the empty repository below. Do not commit the vendor
subdirectory (don't check the boxes for it!) that holds all the Propel files. It's quite large and there's no point. You should commit and push your models
directory and the PHP file you made that displays all the users.
GitHub invite link to the repo:
https://classroom.github.com/a/8cmz3cCI
You can use command line git to directly clone, commit and push your files there on the cloud server without bringing anything down to your local machine. If you're happy using a command-line editor on the cloud server (nano, emacs, vim, vi, etc), then this is a fine solution.
Otherwise, you'll want to edit files locally on your machine and upload them for testing. (Note: Yes, you could test them locally using a LAMP install on your local machine. But since we want to learn about infrastructure, we're going to treat the cloud servers as our official platform). Editing locally is just like what we did with JavaScript. But instead of dragging the file into a local browser, we will upload them and access them over the web. There are two reasonable ways to do this.
This way is easy to set up, but not as convenient in the long run. Start here.
Storage->Browser
from the menu in your GCP consolegsutil cp -r gs://[BUCKET_NAME]/* .
gsutil config -b
and follow the instructions to authorize your VM to access your storage.This way is a pain to set up, but ultimately a more usable workflow. Unfortunately, our lab computers don't currently have FileZilla or the GCP SDK installed. On your own machine, however, you can do so.
gcloud auth login
and follow the directions. It will take you to a browser where you can login and authorize access.view gcloud command
. Copy and paste that into your terminal and run it. Agree to connect if an alert comes up.whoami
and note the username it prints outEdit->Settings
and select SFTP
. Click Add key file...
and add the .ppk
file from the location it gave you earlier (default is c:\Users\{username}\.ssh)).File->Site Manager
and create a new connection with your VM's external IP address, the SFTP protocol and the username that you noted above. No password is needed since it's using SSH keys.If you missed or fell behind the database creation that we did through phpMyAdmin
, here are the details. Please ensure that your database uses the same names (case-sensitive!) so that when we grade it it works with our database as well. There are details about setting up a foreign key in the Propel Relations reference (just pay attention to the database part).
Database name: posting
Table: user
id
: int, primary key, auto_incrementusername
: varchar(32)first_name
: varchar(64)last_name
: varchar(64)join_date
: dateTable: post
id
: int, primary key, auto_incrementuser_id
: int, indexed, foreign key to user.id
(id
in the user
table)content
: textpost_date
: datetimeTable: comment
id
: int, primary key, auto_incrementuser_id
: int, indexed, foreign key to user.id
post_id
: int, indexed, foreign key to post.id
content
: varchar(512)post_date
: datetime