Jump to content

Developer Documentation

Framework Fundamentals

  1. Controllers

    In an MVC application like IPS4, the job of the controller is to handle requests from users. They are, in effect, the middleman, requesting data from the models, doing necessarily processing, and handing it off to the view to display or otherwise output. As discussed in Routing & URLs, methods in controllers map directly to a URL. When you visit a URL like community.com/index.php?app=core&module=messenger&controller=messenger, the controller at /applications/core/modules/front/m
  2. Accessing the database

    Accessing the database to store and query data is a necessity of nearly all applications and plugins that integrate with the Invision Community software. The \IPS\Db class handles database connections, and extends the default mysqli class in the PHP core library. Connecting to the database The default database connection (denoted by the connection details in conf_global.php) can be established automatically by calling \IPS\Db::i(). If a connection has not yet been established, it will
  3. Dates and Times

    Date and time handling is an important function of the software, and the \IPS\DateTime class provides several utility methods to assist with handling dates and times reliably. It is important to note that the \IPS\DateTime class extends the core PHP DateTime class, so all of the general PHP methods for working with dates and times are immediately available through this interface as well. Dates and times are represented in the database by unix timestamps. When displaying a date to a user, ho
  4. Models

    In an MVC application, the Model is responsible for interacting with data, and handing it to the Controller. This is no different in IPS4. Generally speaking, an instance of a model refers to a thing. For example, if you had forums and topics, Forum would be a model, as would Topic. The model for each would then provide methods allowing you to interact with them. When designing models for your application, list the things your application works with - those are li
  5. URLs

    The Invision Community framework provides a powerful helper class to work with URLs, including parsing URLs and making requests to (and reading responses from) URLs. The software automatically uses cURL when available, falling back to standard sockets if not (this behavior can also be overridden by constants if an environment wishes to force cURL or sockets, specifically). Working with URLs The \IPS\Http\Url class is used to work with URLs, and two helper methods form the primary inter
  6. Active Records

    What is an active record? IPS4 makes extensive use of the active record pattern, where each active record object represents a row in your database, and the object provides methods for interacting with that row (including adding new rows). For example, since the \IPS\Member model returns an active record, we can fetch and interact with a member row in the database like so: $member = \IPS\Member::load(1); $member->name = "Dave"; $member->save(); IPS4's base active record class is
  7. Request Data

    The Invision Community software includes a class to work with request data, including GET, POST, and REQUEST data, cookies, and detecting certain information about the request (such as whether it was submitted via AJAX or not). You will need to use this class to perform some common actions working with web-based software. The class is accessed through \IPS\Requst::i() and implements the Singleton pattern. GET, POST and REQUEST data To access request variables, you simply call them as p
×
×
  • Create New...