FuelPHP fundamentals

What is MVC?

MVC stands for Model-View-Controller.

MVC is an approach to separating your code depending on what role it plays. Basically, a request is handled by the controller. It retrieves data using models. Then, it decides what view to use to display the data to your visitors.

See also

MVC in Wikipedia

Where to create my new files?

Every classes follows the same precise naming convention:

  • lowercase, except the first letter of each level in uppercase ;
  • underscores are use to separate directories.

For instance, the classes/controller/admin/login.php file contains the class named Controller_Admin_Login.

PHP classes are placed in the classes directory.

Controllers classes are found in the classes/controller directory.

Models classes belongs in the classes/model directory.

How to write a view?

Views should be put in the views directory.

How to use the ORM?

An ORM does 2 things:

  • it maps your database table rows to PHP objects ;
  • it allows to establish relations between them.

FuelPHP’s ORM uses the Active Record pattern.

The following links from the FuelPHP’s documentation will help you:

See also

Creating models