Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple FuelPHP controller and view for listing blog posts using HMVC and ORM.
<?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'];
}FuelPHP is a flexible, modular PHP framework that supports the HMVC (Hierarchical Model-View-Controller) pattern, designed for developers who need both simplicity and scalability in building web applications.
Origin & Creator
Created by Dan Horrigan in 2010, FuelPHP was developed to provide a modern, secure, and modular PHP framework that supports HMVC while remaining lightweight and flexible.
Industrial Note
FuelPHP is particularly useful for modular applications, scalable web projects, and developers who want HMVC architecture with flexibility for complex enterprise solutions.