Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying FuelPHP Application Development Blueprints
  • Table Of Contents Toc
  • Feedback & Rating feedback
FuelPHP Application Development Blueprints

FuelPHP Application Development Blueprints

By : Sebastien Drouyer
4.4 (5)
close
close
FuelPHP Application Development Blueprints

FuelPHP Application Development Blueprints

4.4 (5)
By: Sebastien Drouyer

Overview of this book

This book is for intermediary to seasoned web developers who want to learn how to use the FuelPHP framework and build complex projects using it. You should be familiar with PHP, HTML, CSS, and JavaScript, but no prior knowledge about MVC frameworks is required.
Table of Contents (8 chapters)
close
close
7
Index

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 be useless, we generate the created_at column manually. As a consequence, we need to specify the CreatedAt observer ourselves. Open the Post model located at APPPATH/classes/model/post.php and add the following attribute:

protected static $_observers...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
FuelPHP Application Development Blueprints
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon