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 [cci]AllowOverride All[/cci] 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:
- Support international character-sets = UTF8 Database
- Have the option for versioning Code.
- Give users the option to follow, change, update, delete their code-snippets they posted if they wish to
Current Model
[cc_yaml]# 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 }
[/cc_yaml]
Some dummy data:
[cc]
# 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
[/cc]
To generate all the stuff just issue the command [cci]$ php symfony doctrine:build –all –and-load[/cci].
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.