This tutorial is heavily inspired by the symfony one.
We will create a blog in very few time. Like symfony, Diem is not designed to build simple blogs, but complex websites. But a blog could be a good starting point.
We will assume you already downloaded Diem, checked your server requirements and created an empty project.
You have now an empty project, and you are able to log into the admin application.
So, the blog will handle posts, and you will enable comments on them.
Edit the config/doctrine/schema.yml and paste the following data model:
Post:
actAs: [ Timestampable, Sortable ]
columns:
title: { type: string(255), notnull: true, unique: true }
excerpt: { type: string(800) }
body: { type: clob, extra: markdown }
image_id: { type: integer }
relations:
Image:
class: DmMedia
local: image_id
Comment:
actAs: [ Timestampable ]
columns:
post_id: { type: integer, notnull: true }
author: { type: string(255) }
body: { type: clob }
relations:
Post:
foreignAlias: Comments
onDelete: CASCADE
Learn more about the schema.yml file in the configuration documentation
Edit the config/dm/modules.yml file and paste the following module description:
Project:
Global:
main: # the main module is required, and must not be removed.
actions:
header:
footer:
Blog:
post:
page: true
actions:
list:
show:
comment:
parent: post
actions:
listByPost:
filters: post
form:
In addition to the main module, we described the post and the comment modules. Note that comment declares its parent : post.
Learn more about the modules.yml file in the module documentation
Now that we described the application, we will let Diem write the code. Run the following command:
$ php symfony dm:setup --clear-db
The --clear-db options will clear the database. It must be used only once : at the very beginning of the project.
Later, we will use doctrine migrations to safely update database without losing previous work.
We worked hard. Now, we want to see the results.
Log into the admin application. In the Content menu ( upper tool bar ) we now can see the "Posts" and "Comments" links.
Click the "Posts" link. You will see an empty list of posts.
We could write fixtures, but we are way too lazy for that, and will let Diem create random posts for us.
On the bottom of the admin posts page, there is a "Loremize" box. Click on 5 to create 5 random posts.
Now we have posts in the blog, with images and text. As the image and excerpt are not required, for some posts they are intentionally left empty.
Do the same operation on the comments admin page. You should create more comments than posts. Comments are randomly linked to posts.
You may want to try the admin features:
Admin interface is fully configurable thanks to the symfony generators
Well, the admin work is complete. Let's create the front application
Questions and Feedback
If you need support or have a technical question, you can