---
title: "Phalcon Application"
version: "5.23"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.phalcon.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Phalcon Application

:::info[NOTE]
All classes are prefixed with `Phalcon`
:::


## Application\AbstractApplication

Abstract

Base class for Phalcon\Cli\Console and Phalcon\Mvc\Application.

- `\stdClass`
  - [`Phalcon\Di\Injectable`](/5.23/api/phalcon_di/#diinjectable)
    - **`Phalcon\Application\AbstractApplication`** - implements [`Phalcon\Events\EventsAwareInterface`](/5.23/api/phalcon_events/#eventseventsawareinterface)
      - [`Phalcon\Cli\Console`](/5.23/api/phalcon_cli/#cliconsole)
      - [`Phalcon\Mvc\Application`](/5.23/api/phalcon_mvc/#mvcapplication)

`Closure` · `Phalcon\Application\Exceptions\ModuleNotRegistered` · `Phalcon\Contracts\Application\ApplicationTypes` · `Phalcon\Di\DiInterface` · `Phalcon\Di\Injectable` · `Phalcon\Events\EventsAwareInterface` · `Phalcon\Events\ManagerInterface` · `Phalcon\Events\Traits\EventsAwareTrait`

### Method Summary

- `public __construct(DiInterface|null $container = null)` — AbstractApplication constructor.

- `public getDefaultModule(): string` — Returns the default module name

- `public getModule(string $name): mixed` — Gets the module definition registered in the application via module name

- `public getModules(): array` — Return the modules registered in the application

- `public registerModules(array $modules, bool $merge = false): static` — Register an array of modules present in the application

- `public setDefaultModule(string $defaultModule): static` — Sets the module name to be used if the router does not return a valid

- `public setEventsManager(ManagerInterface $eventsManager): void` — Sets the events manager

### Properties

- `protected string $defaultModule = ""`

- `protected array $modules = []`

### Methods

<h4 id="applicationabstractapplication-__construct"><code>__construct()</code></h4>

```php
public function __construct( DiInterface|null $container = null );
```

AbstractApplication constructor.

<h4 id="applicationabstractapplication-getdefaultmodule"><code>getDefaultModule()</code></h4>

```php
public function getDefaultModule(): string;
```

Returns the default module name

<h4 id="applicationabstractapplication-getmodule"><code>getModule()</code></h4>

```php
public function getModule( string $name ): mixed;
```

Gets the module definition registered in the application via module name

<h4 id="applicationabstractapplication-getmodules"><code>getModules()</code></h4>

```php
public function getModules(): array;
```

Return the modules registered in the application

<h4 id="applicationabstractapplication-registermodules"><code>registerModules()</code></h4>

```php
public function registerModules(
    array $modules,
    bool $merge = false
): static;
```

Register an array of modules present in the application

```php
$this->registerModules(
    [
        "frontend" => [
            "className" => \Multiple\Frontend\Module::class,
            "path"      => "../apps/frontend/Module.php",
        ],
        "backend" => [
            "className" => \Multiple\Backend\Module::class,
            "path"      => "../apps/backend/Module.php",
        ],
    ]
);
```

<h4 id="applicationabstractapplication-setdefaultmodule"><code>setDefaultModule()</code></h4>

```php
public function setDefaultModule( string $defaultModule ): static;
```

Sets the module name to be used if the router does not return a valid
module

<h4 id="applicationabstractapplication-seteventsmanager"><code>setEventsManager()</code></h4>

```php
public function setEventsManager( ManagerInterface $eventsManager ): void;
```

Sets the events manager


## Application\Exception

Class

Exceptions thrown in Phalcon\Application use this class

- `\Exception`
  - **`Phalcon\Application\Exception`**
    - [`Phalcon\Application\Exceptions\ModuleNotRegistered`](#applicationexceptionsmodulenotregistered)
    - [`Phalcon\Cli\Console\Exception`](/5.23/api/phalcon_cli/#cliconsoleexception)
    - [`Phalcon\Mvc\Application\Exception`](/5.23/api/phalcon_mvc/#mvcapplicationexception)


## Application\Exceptions\ModuleNotRegistered

Class

- `\Exception`
  - [`Phalcon\Application\Exception`](#applicationexception)
    - **`Phalcon\Application\Exceptions\ModuleNotRegistered`**

`Phalcon\Application\Exception`

### Method Summary

- `public __construct(string $name)`

### Methods

<h4 id="applicationexceptionsmodulenotregistered-__construct"><code>__construct()</code></h4>

```php
public function __construct( string $name );
```

Source: https://docs.phalcon.io/5.23/api/phalcon_application/index.mdx
