Ocs-server/Gfx4/Folders and MVC

The Gfx frameworks consist of a root directory that contains basically the source directory that's (still) called gfx3, a standard index.php and .htaccess file responsible for the rewriting stuff.

In order to prepare your server to host a Gfx application please refer to the Configuring a webserver as host guide, since ocs-server is built around Gfx (or, in many cases, the contrary).

Unzipping our latest package in your DocumentRoot will create a standard directory tree for you.

Gfx root folder structure

  • index.php: handles every request. Shouldn't be moved or modified.
  • .htaccess: responsible for Gfx URL rewriting, shouldn't be moved or modified.
  • /gfx3/src: contains all the source of Gfx
  • /gfx3/libs: put here any php file that will be loaded and handled as an external library available for all subsites.
  • /gfx3/docs: contains some small hand txt documentation files (can be outdated)

Main site and subsites folder structure

  • /config: contains all the configuration files of the website
  • /models: contains all the models
  • /controllers: contains all the controllers
  • /views: contains all the views
  • /libs: contains all the third part libraries

In order to create a sub-website with its config, models etc... just create a folder called "config" inside the folder you want to become a subsite. Remember to create a proper generic.conf.php, database.conf.php and rewrite.conf.php. Grab them from the main website and then modify them according to your needs if you don't know how to write them.

Finding paths

There's a handy class that stores all useful absolute paths: ELoader. This class is also responsible for the actual load and execution of the Gfx framework.

Let's suppose we have installed Gfx in /var/www/html which responds to http://localhost. URL called is http://localhost/admin. Then ELoader will have those attributes set:

  • ELoader::$prev_path = /var/www/html
  • ELoader::$abs_path = /var/www/html/gfx/src
  • ELoader::$root_path = localhost or the host of your choice
  • ELoader::$subsite_path = /admin
  • ELoader::$cache_path = /var/www/html/gfx3/cache
  • ELoader::$libs_path = /var/www/html/gfx3/libs
  • ELoader::$config_path = /var/www/html/admin/config
  • ELoader::$controllers_path = /var/www/html/admin/controllers
  • ELoader::$models_path = /var/www/html/admin/models
  • ELoader::$views_path = /var/www/html/admin/views
  • ELoader::$locallibs_path = /var/www/html/admin/libs

Other webpage properties

The class EPageProperties has some userful methods that gives infos about the current web page.

This page was last edited on 28 July 2015, at 11:11. Content is available under Creative Commons License SA 4.0 unless otherwise noted.