Learn FUELPHP with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
FuelPHP Simple Blog App
<?php
// classes/controller/post.php
class Controller_Post extends Controller {
public function action_index() {
$posts = Model_Post::find('all');
return View::forge('post/index', ['posts' => $posts]);
}
public function action_view($id) {
$post = Model_Post::find($id);
return View::forge('post/view', ['post' => $post]);
}
}
// views/post/index.php
<h1>Blog Posts</h1>
<ul>
<?php foreach ($posts as $post): ?>
<li><a href="<?php echo Uri::create('post/view/' . $post->id); ?>"><?php echo $post->title; ?></a></li>
<?php endforeach; ?>
</ul>
// classes/model/post.php
class Model_Post extends Orm\Model {
protected static $_properties = ['id', 'title', 'content'];
}
Demonstrates a simple FuelPHP controller and view for listing blog posts using HMVC and ORM.