1. Home
  2. /
  3. Fuelphp
  4. /
  5. Simple Blog App

Simple Blog App - Fuelphp Typing CST Test

Loading…

Simple Blog App — Fuelphp Code

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 Language Guide

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.

Primary Use Cases

  • ▸Building modular PHP web applications
  • ▸Creating RESTful APIs and services
  • ▸Rapid prototyping with HMVC structure
  • ▸Developing scalable enterprise applications
  • ▸Integration with third-party services and packages

Notable Features

  • ▸HMVC architecture for modular applications
  • ▸Built-in ORM for database abstraction
  • ▸Security features including CSRF, XSS, and input filtering
  • ▸Flexible routing and REST support
  • ▸Package system for modular development

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.

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher