O'Reilly logo

FuelPHP Application Development Blueprints by Sébastien Drouyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Allowing the user to create and view posts

We will now allow users to create their own posts and display them in their profile page. Posts will also be the main information displayed by our API.

Generating the Post model

We need first to generate the Post model. As usual, we will use oil. Enter the following command line:

php oil generate model post content:varchar[140] user_id:int created_at:int --no-timestamp

The output is as follows:

Creating model: APPPATH/classes/model/post.php
Creating migration: APPPATH/migrations/001_create_posts.php

You can see that we used the --no-timestamp parameter here. It simply prevents the automatic generation of the created_at and updated_at columns. Since we can have a lot of posts and the updated_at column then ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required