Skip to content

Installation

The DotApp application is not installed in the standard way via composer install because it is not a library but a complete application with its own architecture. Instead, follow these steps:

1. Install the application using Git:

git clone https://github.com/dotsystems-sk/dotapp.git ./

This command clones the repository into the current directory.

Alternatively, you can download the ZIP file:

Download dotApp

Unzip it into the directory where you need to place the application.

2. Setup and Usage:

After cloning or unzipping the application, configure it according to your needs (e.g., database configuration, environment settings, etc.).

3. Using Composer:

Although the application itself is not installable via Composer, once installed, you can use Composer within the application directory to add additional dependencies required for your project. Simply run:

composer require

Directory structure. Application logic lives in app/modules/{ModuleName}/. app/parts/ is the framework core.

project-root/
├── index.php                 # front controller
├── dotapper.php
├── app/
│   ├── config.php            # secrets, databases, drivers
│   ├── modules/              # your modules
│   │   └── HelloWorld/
│   │       ├── module.init.php
│   │       ├── module.listeners.php
│   │       ├── Controllers/
│   │       ├── Middleware/
│   │       ├── Models/
│   │       ├── views/
│   │       └── assets/
│   ├── parts/                # framework core — do not edit
│   ├── runtime/
│   └── vendor/
└── assets/
    └── modules/              # public files served from each module's assets/

Post-Installation Setup

This section describes the minimal setup required after installing the DotApp framework. If you don’t need to work with databases or prefer your own solution over the built-in library, simply follow these steps:

1. (Optional) Override __ROOTDIR__ in index.php

By default, index.php sets __ROOTDIR__ to its own directory. Define it only when the application root is somewhere else (no trailing slash):

define('__ROOTDIR__', "/var/www/html");

Ensure that __ROOTDIR__ matches the actual server location, otherwise the framework may not function correctly.


2. Set a unique encryption key in ./app/config.php

Config::set("app", "name", "MyApp");
Config::set("app", "c_enc_key", "ReplaceThisWithALongRandomSecret");
$dotApp = new \Dotsystems\App\DotApp();

Use a unique, long secret (at least 32 characters). Do not pass md5(...) into the DotApp constructor.


3. (Optional) Database — uncomment and fill the sample in ./app/config.php

use Dotsystems\App\Parts\Config;

if (!__MAINTENANCE__) {
    Config::addDatabase(
        "main",
        "127.0.0.1",
        "username",
        "password",
        "dbname",
        "UTF8",
        "MYSQL",
        "pdo"
    );
}

$dotApp = new \Dotsystems\App\DotApp();
$dotApp->load_modules();
            

Running the Framework

After app/config.php loads modules, index.php starts the application. Routes are declared in each module’s module.init.php. The start call is:


// Everything ready? Start the framework! - As seen in the index.php file
$dotApp->davajhet();
// or in English:
$dotApp->run();

/*
    Note: $dotApp->davajhet() is an alias for $dotApp->run().
    I come from eastern Slovakia, so I added a bit of our "davaj het!" (let's go!)
*/
            

Adding the First Route

Blank page and ERROR 404? If you followed the instructions and see a blank page with a 404 status code after starting, don’t worry. It’s logical. The router is empty, so it couldn’t find a route for the / address in your browser and correctly displayed a 404. Your framework has no modules or routes yet, so it’s doing what it’s supposed to. Add the first route in a module initialize() method.


<?php
// app/modules/HelloWorld/module.init.php
namespace Dotsystems\App\Modules\HelloWorld;

use Dotsystems\App\Parts\Router;

class Module extends \Dotsystems\App\Parts\Module
{
    public function initialize($dotApp)
    {
        Router::get("/", function ($request) {
            return "Hello World!";
        }, Router::STATIC_ROUTE);
    }

    public function initializeRoutes()
    {
        return ['/', '/*'];
    }
}

new Module($dotApp);
        

After running, we see a page with the content:

Hello World!