Episode completed

Next epsiode starting in 3 seconds

Published at

Script

If you didn’t follow the set up video - You need to run ihp-new with the desired name for your project to create it. After creating the project, we can start the DevServer by running ./start in the project folder. Your default browser will be opened. Here, we can start building our blog, by setting up the schema. This explains your database how to store the data. For example: If we want to save blog posts, we can create a table named posts. Every post must have an identifier. That’s why the table automatically has an id field. Next, we need to define what a post is. To do that, we can add a column named “title”, which has the type “Text”. We also need to store the content of the post, so we add another text column with the name “body”. To conclude, we have a table for posts, which can store an identifier, a title and a body for every post. To apply these changes to our database, you need to click “Update DB”. This will save any content in your database, if there is any, and updates the changes. Now our database knows how to store posts, but we want to create an interface for the user to see, create, edit and delete posts. To do that, IHP has an included Codegen feature, which can generate Controllers and Views. Let’s generate the Posts Controller first. You can use the Codegen section to manually generate stuff, but you can also just right-click a table to generate a controller for it. A controller manages the possible actions for something. For example, the Posts controller we need to create, includes actions for showing, creating, editing and deleting posts. The convenient thing about the Codegen feature is that everything from Routing to creating Types is covered, so you don’t need to add this manually over and over again. Because of this, we can just open our app and see the generated code working instantly. We can even start creating posts. And with that, the core functionality of our blog is done.

Discussion