Jump to content

Developer Documentation

Structuring your application

An application within IPS4 is made up of several types of class, and you'll use most of them in your own applications. The structure of your application files is well defined (it's this structure that allows classes to be autoloaded when needed.

Structure overview

Within your application directory, here's the structure and what each directory contains (some optional directories are omitted here). We'll examine the key parts shortly.

  • /Application.php
    Your main application bootstrap file.
  • /api
    Contains REST API endpoints if the application supports the REST API.
  • /data
    Holds numerous json files that configure your application settings, schema and more, typically used on installation.
  • /dev
    Only exists when you are in developer mode.
    • /css
      Contains CSS files for front/admin locations
    • /email
      Contains templates for notification emails sent by your application
    • /html
      Contains all of the HTML templates for the front/admin locations that your application will use
    • /js
      Contains the javascript controllers and templates for the front/admin locations that your application will use.
    • /resources
      Contains other kinds of resources (e.g. images, fonts, sounds) that your application will use.
  • /extensions
    Contains the various Extensions that your application might use.
  • /hooks
    Contains any hooks that your application uses.
  • /modules
    This is where your controllers live. This directory is divided into:
    • /admin
      Contains your admin controller modules.
      • /<module_name>
      • /<module_name_2> etc.
    • /front
      Containers your front-end (public) controller modules
      • /<module_name>
      • /<module_name_2> etc.
  • /setup
    Installation and upgrade scripts that your application will use when required.
  • /sources
    The directory containing your models.
    • /<model_type>
    • /<model_type_2> etc.
  • /tasks
    Contains scripts that are executed periodically by IPS4's task system.
  • /widgets
    Contains scripts that will output widgets, to be used in IPS4's block manager system.

\IPS\Application::getRootPath();

If you need to reference the path to your application files then the \IPS\Application::getRootPath( 'appkey' ) method should be used. This is to make sure the correct path is used regardless of the server environment.


  Report Document


×
×
  • Create New...