$skip_page_style : boolean

Set this variable to true during the handle phase of your component to not show the site's style around the component output. This is mainly targeted at XML output like RSS feeds and similar things. The output handler of the site, excluding the style-init/-finish tags will be executed immediately after the handle phase, and midcom->finish() is called automatically afterwards, thus ending the request.

Changing this flag after the handle phase or for dynamically loaded components won't change anything.




$serviceloader : \midcom_helper_serviceloader




$i18n : \midcom_services_i18n




$componentloader : \midcom_helper__componentloader




$dbclassloader : \midcom_services_dbclassloader




$dbfactory : \midcom_helper__dbfactory




$head : \midcom_helper_head




$style : \midcom_helper__styleloader




$auth : \midcom_services_auth




$permalinks : \midcom_services_permalinks




$toolbars : \midcom_services_toolbars




$uimessages : \midcom_services_uimessages




$metadata : \midcom_services_metadata




$rcs : \midcom_services_rcs




$session : \midcom_services__sessioning




$indexer : \midcom_services_indexer




$config : \midcom_config




$cache : \midcom_services_cache




$dispatcher : \midcom\events\dispatcher




$debug : \midcom_debug




$_cached_host_prefix : string

Host prefix cache to avoid computing it each time.




$_cached_page_prefix : string

Page prefix cache to avoid computing it each time.




$request : \Symfony\Component\HttpFoundation\Request







__get(  $key) 

Magic getter for service loading




__set(  $key,   $value) 

Magic setter





Main MidCOM initialization.

Initialize the Application class. Sets all private variables to a predefined state.



Initialize the URL parser and process the request.

This function must be called before any output starts.


dynamic_load(string  $url, array  $config = array(),   $pass_get = false) : integer

Dynamically execute a subrequest and insert its output in place of the function call.

Important Note As with the Midgard Parser, dynamic_load strips a trailing .html from the argument list before actually parsing it.

It tries to load the component referenced with the URL $url and executes it as if it was used as primary component. Additional configuration parameters can be appended through the parameter $config.

This is only possible if the system is in the Page-Style output phase. It cannot be used within code-init or during the output phase of another component.

Example code, executed on a site's homepage, it will load the news listing from the given URL and display it using a substyle of the node style that is assigned to the loaded one:

$blog = '/blog/latest/3/'; $substyle = 'homepage'; midcom::get()->dynamic_load("/midcom-substyle-{$substyle}/{$blog}");

Results of dynamic_loads are cached, by default with the system cache strategy but you can specify separate cache strategy for the DL in the config array like so midcom::get()->dynamic_load("/midcom-substyle-{$substyle}/{$newsticker}", ['cache_module_content_caching_strategy' => 'public'])

You can use only less specific strategy than the global strategy, ie basically you're limited to 'memberships' and 'public' as values if the global strategy is 'user' and to 'public' the global strategy is 'memberships', failure to adhere to this rule will result to weird cache behavior.


string $url

The URL, relative to the Midgard Page, that is to be requested.

array $config

A key=>value array with any configuration overrides.



integer —

The ID of the newly created context.


serve_attachment(\midcom_db_attachment  $attachment, integer  $expires = -1) 

Deliver a blob to the client. It will add the following HTTP Headers:

  • Cache-Control: public max-age=$expires
  • Expires: GMT Date $now+$expires
  • Last-Modified: GMT Date of the last modified timestamp of the Attachment
  • Content-Length: The Length of the Attachment in Bytes
  • Accept-Ranges: none

This should enable caching of browsers for Navigation images and so on. You can influence the expiration of the served attachment with the parameter $expires. It is the time in seconds till the client should refetch the file. The default for this is 24 hours. If you set it to "0" caching will be prohibited by changing the sent headers like this:

  • Pragma: no-cache
  • Cache-Control: no-cache
  • Expires: Current GMT Date

If expires is set to -1, no expires header gets sent.


\midcom_db_attachment $attachment

The attachment to be delivered.

integer $expires

HTTP-Expires timeout in seconds, set this to 0 for uncacheable pages, or to -1 for no Expire header.



Exit from the framework, execute after all output has been made.

Does all necessary clean-up work. Must be called after output is completed as the last call of any MidCOM Page.

WARNING: Anything done after calling this method will be lost.


get_host_name() : string

Retrieves the name of the current host, fully qualified with protocol and port.


string —

Full Hostname (http[s]://[:1234])


get_page_prefix() : string

Return the prefix required to build relative links on the current site.

This includes the http[s] prefix, the hosts port (if necessary) and the base url of the Midgard Page. Be aware, that this does not point to the base host of the site.

e.g. something like http[s]://[:8080]/host_prefix/page_prefix/


string —

The current MidCOM page URL prefix.


get_host_prefix() : string

Return the prefix required to build relative links on the current site.

This includes the http[s] prefix, the hosts port (if necessary) and the base url of the main host. This is not necessarily the currently active MidCOM Page however, use the get_page_prefix() function for that.

e.g. something like http[s]://[:8080]/host_prefix/


string —

The host's root page URL prefix.


header(string  $header, integer  $response_code = null) 

Sends a header out to the client.

This function is syntactically identical to the regular PHP header() function, but is integrated into the framework. Every Header you sent must go through this function or it might be lost later on; this is especially important with caching.


string $header

The header to send.

integer $response_code

HTTP response code to send with the header


relocate(string  $url, string  $response_code = 302) 

Relocate to another URL.

The helper actually can distinguish between site-local, absolute redirects and external redirects. If the url does not start with http[s] or /, it is taken as a URL relative to the current anchor prefix, which gets prepended automatically (no other characters as the anchor prefix get inserted).

Fully qualified urls (starting with http[s]) are used as-is.

Note, that this function automatically makes the page uncacheable, calls midcom_finish and exit, so it will never return. If the headers have already been sent, this will leave you with a partially completed page, so beware.


string $url

The URL to redirect to, will be preprocessed as outlined above.

string $response_code

HTTP response code to send with the relocation, from 3xx series



Raise some PHP limits for resource-intensive tasks


_process(\midcom_core_context  $context) : \midcom_response

Process the request

Basically this method will parse the URL and search for a component that can handle the request. If one is found, it will process the request, if not, it will report an error, depending on the situation.

Details: The logic will traverse the node tree, and for the last node it will load the component that is responsible for it. This component gets the chance to accept the request, which is basically a call to can_handle. If the component declares to be able to handle the call, its handle function is executed. Depending if the handle was successful or not, it will either display an HTTP error page or prepares the content handler to display the content later on.

If the parsing process doesn't find any component that declares to be able to handle the request, an HTTP 404 - Not Found error is triggered.


\midcom_core_context $context




_output(\midcom_core_context  $context,   $include_template, \midcom_response  $response) 

Execute the output callback.

Launches the output of the currently selected component. It is collected in an output buffer to allow for relocates from style elements.

It executes the content_handler that has been determined during the handle phase. It fetches the content_handler from the Component Loader class cache.


\midcom_core_context $context
\midcom_response $response