As we continue to update our products, most of them are now using the same framework based on the MVC model.  The MVC model is a method to develop a software in three parts - Model, View and Controller (MVC). The Model is the part where logic is defined, for example the type of fields that user has - name, email, phone, last login, unique ID, etc... The View part is the output of the software. These are the layouts and templates. The Controllers is where the magic happens – the code in the controllers accepts the input, manipulates the data and sends back all the output to the “views”. As you can imagine this makes it super easy even for a non experienced person to make small changes to the code. If for example you need to change the front end layout you only have to work with “views” and there is no need of more complex code in the controllers.


You can find all PHPjabbers' scripts that currently support the new framework at the bottom of the "One admiN" presenation page.


Now lets talk about folder and file structure. I will present some general information about how files and folders are organized. In the upcoming weeks we will also post another articles related to different parts of the PHP framework - components, plugins, creating SQL, how multi lang is organized, etc..


Root folder

In the root folder you will see two sub-folders /app/ and /core/.


The /app/ folder is where all the specific files are located - models, controllers, views, options, plugins, css, js, data files, etc.. If you need to make a change to any part of the script - functionality or design - this is the folder where you should look. We will discuss it later in the post.


The files in the /core/ folder are code libraries that are used by our scripts. Instead of writing the same piece of code multiple times we’ve created a code library for these repeatedly used functions. For example we have pjEmail.component.php which is used to send emails. Of course it handles mail() and SMTP methods, file attachments, multiple recipients, etc.. which makes the PHP code used very long. To avoid writing the same long PHP code for sending an email when an email has to be sent we just call a function defined in that pjEmail.component.php file. This saves a lot time writing the code, studying it and modifying it. This is a very productive way to code because if you ever need to make a change to the mail sending code you need to update it in one place only - the email component file.


In the /core/ folder there are also folders for external libraries (such as jQuery, TinyMCE, et..).


There are also a couple of obfusticated files which as per our license agreement you cannot change. These files are used to process and manipulate the data on a low level so as long as you understand the MVC model logic you will not need to do any changes to them anyway. 


The /app/config/ folder


In that folder you can find script configuration files. When you install the product, the file is generated together with all the necessary information in it - MySQL login details, server installation path and URL. So if you ever decide to change the MySQL database password for your server you need to open file and change the password there too. Please, note that before you install our product, this file is empty (0 bytes). Also depending on your server configuration, write permissions to it may need to be set. This is of course checked by our installer wizard and you will be notified if such permissions need to be set.


There is also database.sql file where all the SQL queries to set up the script are stored. So when you make a fresh installation and run the installer it will execute all the queries found in this file.


The /app/models/ folder


You can find all models for our software in /app/models/ folder. There you can see a different file for each of the product’s specific features. A model that is pretty much the same for all our products is pjUser.model.php.  In that file we have the fields defined for each user plus the type of these fields, their default values and validation types. This is basically a PHP class which defines the data type. So if you decide to add a new field for your users one of the places where you should add it is the model file.


The /app/controllers/ folder


In this folder you can find the controllers for the product. These are the files which process all the data. There is a different controller file for each product element. For example the controller for managing user accounts is pjAdminUsers.controller.php


Within the file you will find different functions which are used to manipulate the data. A typical functions would be

  • pjActionCreate() - to create a new user
  • pjActionUpdate() - to update an existing user
  • pjActionDeleteUser() - to delete an user


As you can see we have named the functions in an easy to read format. So when you see a function such as pjActionExportUser you will know that it is used to export user(s) details.


The /app/plugins/ folder


In this folder you can find different plugins that are the same for the different products that we have. For example pjOneAdmin is a good example for a plugin which works the same way in all our products. Each plugin is built using the MVC model and consist of models, views and controller files.


The /app/views/ folder


Here you can find all the web page templates - or so called “Views” in the MVC model. So if you want to change the layout of a particular page you need to look into this folder. As you can see the folders and file names are named in an easy to read format so you can easily understand what each file is about.

Lets open the “pjAdminUsers”. By its name you can imagine that there you can find the page templates used for managing user accounts - list, add, edit pages. You will see these files in the folder.


  • pjActionCreate.php - this is the template for the create new user page
  • pjActionIndex.php - this is the template for the list all users page
  • pjActionUpdate.php - this is the template for view and edit user pages


The /app/web/ folder

The last folder is the /web/ folder. If you open the folder you will see that there are different subfolders where all JavaScript and CSS styles are stored. There are also a couple of folders used by the plugins - backup, invoice, etc. If the product that you use lets you upload images (for example Vacation Rental script where you upload images for each property) then you will have /uploads/ sub-folder where these images will be uploaded.


URL structure - views and controllers

The index.php file in script root folder is the file which processes all the information. Both the backend and front end are loaded through that file but depending on the parameters passed different information is shown. The format of the URL gives you a lot of information about what the controller and views are used. For example when you are logged into the administration page and go to Users page the URL in your browser will be as shown below:



Analyzing the URL structure you can find that:

  • the controller file you should be looking at is /app/controllers/pjAdminUsers.controller.php
  • the PHP function which is called to generate all the content you see on that page is in the pjAdminUsers.controller.php file and is called pjActionIndex()
  • the web page template file is /app/views/pjAdminUsers/pjActionIndex.php


If you go to Edit user page the URL will change to:



and hence:

  • the controller file is still /app/controllers/pjAdminUsers.controller.php
  • however the PHP function is now pjActionUpdate()
  • and the web page template file is /app/views/pjAdminUsers/pjActionUpdate.php


I hope this article is a good starting point for you to study and use our MVC framework. You may also check this page for details about MVC. Thank you for reading!