Tutorial #1: Admin

Create a first basic website : admin application

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.

Create a project

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.

Initialize the data model

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:

  actAs:              [ Timestampable, Sortable ]  
    title:            { type: string(255), notnull: true, unique: true }  
    excerpt:          { type: string(800) }  
    body:             { type: clob, extra: markdown }  
    image_id:         { type: integer }  
      class:          DmMedia  
      local:          image_id  

  actAs:              [ Timestampable ]  
    post_id:          { type: integer, notnull: true }  
    author:           { type: string(255) }  
    body:             { type: clob }  
      foreignAlias:   Comments  
      onDelete:       CASCADE  

Learn more about the schema.yml file in the configuration documentation

Initialize the modules

Edit the config/dm/modules.yml file and paste the following module description:



    main:               # the main module is required, and must not be removed.  


      page:             true  

      parent:           post  
          filters:      post  

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

Apply changes

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.

Rest a bit and have some fun

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.

Auto generated list of posts

Create some dummy 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.

Play with admin

You may want to try the admin features:

  • create, update and delete posts and comments
  • sort posts
  • add images to the posts
  • try the posts markdown editor
  • use the pagination and the search engine

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

  • Post to the google group
  • Come and chat on the #diem IRC channel on freenode