Community Documentation

v3 Knowledgebase

Creating a Page (Controller Method)

For developers starting out with phpFox we guide them to first check out our article "Creating Your First Add-on" as it takes you through all the steps on how to work with services, controllers, plug-ins within an independent module.

However, if you just want to create a PHP page utilizing our controller system you do not need to create a new product or module. You can actually place your page (controller) within any active module.

You can also create a page easily from your AdminCP using our CMS tools, however in this article we will go over on how to create a page using PHP files as for some developers this is easier and gives them a lot more freedom when working with code.

The goal with this article is to also use it as a reference on how to create a basic controller as other articles require the knowledge of working with a controller.

In this example we will create a new page called "example". Once it is ready you will be able to access it on your site by going to:
or if you have short URLs enabled:

Creating the PHP File

First, let's create the PHP controller file. Create a new file called example.class.php and place it in the folder:

In that file paste the following PHP code:

class Core_Component_Controller_Example extends Phpfox_Component
    public function 


When creating controllers the part you need to modify each time when creating a PHP class is the following:

Since the name of the page we are working with is example the suffix of the class name is _Example. The prefix in this case is Core_ and this is the name of the module we placed our file in. If you placed a new file in the friend module the suffix would then be Friend_.

Creating the HTML File

Now that we have created the PHP file let's create an HTML file. To do that create a new file called "example.html.php" and place it in the folder:

In that file paste the following:
Hello World!

That's it. Now visit the page we just created and you should see "Hello World!".

Remember you can place this file in any module folder. All that will change is the name of the class you create and the access point.