The Factory

Official Documentation: https://docs.joomla.org/Using_the_JFactory_class

The JFactory class sites at the root of the /libraries/src folder and provides a bunch of static functions to get various Joomla services which are mostly singletons. The JFactory is used everywhere in Joomla code - it's the global service locator for both core and extensions.

The Factory on github: https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Factory.php

JFactory::getApplication()

Returns the JApplicationCMS, through it you can access for the example do redirects, access the configuration and the input variables, the Menu or enqueue messages which are shown to the user.

JFactory::getDocument()

Provides access to the current JDocument, with it you can set Meta data, add styles and scripts and more related to the document.

JFactory::getDbo()

Returns a database object, with it you query to the database ($query = JFactory::getDbo()->getQuery(true)), secure your input before sending it and load entries.

JFactory::getUser()

Returns the current Joomla! user object (JUser), with it you can access information and methods related to users. It is also created for guests, where the id is zero.

JFactory::getDate()

Returns a How to use JDate instance, you can also add a time and a timezone offset to it. Without parameters it uses the current time.

JFactory::getMailer()

Provides access to the Joomla Mailer (wrapper around PHPMailer) for sending emails with Joomla.

JFactory::getConfig()

Returns a registry with the Joomla! configuration file (configuration.php), see JConfig for more details. To access single values you can use JFactory::getApplication()->get('configValue')

JFactory::getSession()

Returns the current visitors session. (Make sure Joomla! is called as Webapplication)