> For the complete documentation index, see [llms.txt](https://sprnva.gitbook.io/sprnva-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sprnva.gitbook.io/sprnva-docs/controllers.md).

# Controllers

Sprnva is a MVC approach so we also have a Controller which all the logics of our page is stored and processed.

Controller is the medium where logic, database and view meet.\
Controller also is the processing area of all the logics to be fetch later in the views.

\
You will find the controller at `app/controllers`. Then this is how you declare a basic controller.

```php
<?php

namespace App\Controllers;

class WelcomeController
{
    protected $pageTitle;

    public function index()
    {
        $pageTitle = "Home";

        return view('/home', compact('pageTitle'));
    }
}
```

<mark style="color:red;">**ALWAYS REMEMBER WHEN ADDING A CLASS, DON'T FORGET TO ADD IT'S NAMESPACE AND RE-INITIALIZE THE CLASS AUTOLOADER USING COMPOSER.**</mark>

This is how you re-initialize class autoloader using composer.

```bash
composer dump-autoload
```
