Download the PHP package joomla/application without Composer
On this page you can find all versions of the php package joomla/application. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download joomla/application
More information about joomla/application
Files in joomla/application
Package application
Short Description Joomla Application Package
License GPL-2.0-or-later
Homepage https://github.com/joomla-framework/application
Informations about the package application
The Application Package 
Initialising Applications
AbstractApplication implements an initialise method that is called at the end of the constructor. This method is intended to be overridden in derived classes as needed by the developer.
If you are overriding the __construct method in your application class, remember to call the parent constructor last.
Logging within Applications
AbstractApplication implements the Psr\Log\LoggerAwareInterface so is ready for integrating with an logging package that supports that standard.
The following example shows how you could set up logging in your application using initialise method from AbstractApplication.
The logger variable is private so you must use the getLogger method to access it. If a logger has not been initialised, the getLogger method will throw an exception.
To check if the logger has been set, use the hasLogger method. This will return true if the logger has been set.
Consider the following example:
Mocking the Application Package
For more complicated mocking where you need to similate real behaviour, you can use the Application\Tests\Mocker class to create robust mock objects.
There are three mocking methods available:
createMockBasewill create a mock forAbstractApplication.createMockCliwill create a mock forAbstractCliApplication.createMockWebwill create a mock forAbstractWebApplication.
The createMockWeb method will return a mock with the following methods mocked to roughly simulate real behaviour albeit with reduced functionality:
appendBody($content)get($name [, $default])getBody([$asArray])getHeaders()prependBody($content)set($name, $value)setBody($content)setHeader($name, $value [, $replace])
You can provide customised implementations these methods by creating the following methods in your test class respectively:
mockWebAppendBodymockWebGetmockWebGetBodymockWebGetHeadersmockWebSetmockWebSetBodymockWebSetHeader
Web Application
Configuration options
The AbstractWebApplication sets following application configuration:
-
Execution datetime and timestamp
execution.datetime- Execution datetimeexecution.timestamp- Execution timestamp
- URIs
uri.request- The request URIuri.base.full- full URIuri.base.host- URI hosturi.base.path- URI pathuri.route- Extended (non-base) part of the request URIuri.media.full- full media URIuri.media.path- relative media URI
and uses following ones during object construction:
gzipto compress the outputsite_urito see if an explicit base URI has been set (helpful when chaining request uri using mod_rewrite)media_urito get an explicitly set media URI (relative values are appended touri.base). If it's not set explicitly, it defaults to amedia/path ofuri.base.
The setHeader method
Accepted parameters
$name- The name of the header to set.$value- The value of the header to set.$replace- True to replace any headers with the same name.
Example: Using WebApplication::setHeader to set a status header.
Will result in response containing header
Command Line Applications
The Joomla Framework provides an application class for making command line applications.
An example command line application skeleton:
Colors for CLI Applications
It is possible to use colors on an ANSI enabled terminal.
You can also create your own styles.
Available foreground and background colors are: black, red, green, yellow, blue, magenta, cyan and white.
And available options are: bold, underscore, blink and reverse.
You can also set these colors and options inside the tagname:
Installation via Composer
Add "joomla/application": "~4.0" to the require block in your composer.json and then run composer install.
Alternatively, you can simply run the following from the command line:
If you want to include the test sources, use
All versions of application with dependencies
psr/log Version ^1.0|^2.0|^3.0
psr/http-message Version ^2.0
joomla/event Version ^4.0
joomla/registry Version ^4.0
laminas/laminas-diactoros Version ^3.6.0
symfony/deprecation-contracts Version ^2|^3