nopaste.at recode with symfony. Part 2: THE START!

The TODO for Today

  • Setup the VHost
  • Create a decent database model

Doesn’t sound like much, let’s see what i came up with.

VHost+Database setup

Doing this with Apache and phpMyAdmin isn’t big of a deal.

Just make sure to set AllowOverride All for your VHost or the symfony won’t play nicely.

The Model

Since thats the first time i’m using a database design tool like doctrine i had quite a rough time figuring some stuff out.

Things i want to be able to:

  1. Support international character-sets = UTF8 Database
  2. Have the option for versioning Code.
  3. Give users the option to follow, change, update, delete their code-snippets they posted if they wish to

Current Model

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# config/doctrine/schema.yml
pasteUser:
options:
type: InnoDB
collate: utf8_unicode_ci
charset: utf8
columns:
level: { type: integer, default: 5 }
email: { type: string(255), notnull: true, unique: true }
password: { type: string(40), notnull: true }

pasteCode:
options:
type: InnoDB
collate: utf8_unicode_ci
charset: utf8
columns:
user_id: { type: integer, notnull: true }
hash: { type: string(30), notnull: true, unique: true }
revision: { type: integer, notnull: true }
code: { type: text, notnull: true }
is_public: { type: boolean, default:1 }
post_date: { type: timestamp, notnull: true }
relations:
pasteUser: { local: user_id, foreign: id  }

pasteImage:
options:
type: InnoDB
collate: utf8_unicode_ci
charset: utf8
columns:
user_id: { type: integer, notnull: true }
hash: { type: string(30), notnull: true, unique: true }
is_public: { type: boolean, default:1 }
post_date: { type: timestamp, notnull: true }
file: { type: string(255), notnull: true }
relations:
pasteUser: { local: user_id, foreign: id }

Some dummy data:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# data/fixtures/pasteCode.yml
pasteCode:
code1:
user_id: 1
hash: ABF123412A
code: dummy
code2:
user_id: 1
hash: GGFFDD12
code: dummy2
# data/fixtures/pasteImage.yml
pasteImage:
image1:
user_id: 1
hash: FFEF1232
file: dummy
image2:
user_id: 1
hash: FFGG1787
file: dummy2
# data/fixtures/pasteUser.yml
pasteUser:
normal:
level: 5
email: some@mail-ad-re-s.o.r.g
password: d8e8fca2dc0f896fd7cb4cb0031ba249
admin:
level: 0
email: some_other@mail-ad-re-s.o.r.g
password: d8e8fca2dc0f896fd7cb4cb0031ba249

To generate all the stuff just issue the command $ php symfony doctrine:build --all --and-load.

Checklist

  • Used UTF-8 in our Database so we are able to support International CharacterSets: check
  • Taken care of versioning: check
  • CRUD for Users: somewhat done we store the user-id’s thus there should be no problem.
Bookmark and Share

Leave a Reply