Base code

Namespaces must be created by following the principle used in JAVA to manage packages. The “src” folder is the root class folder.

Base code

So, in the “src” folder, any subfolder will be included in the namespace.

– The “MyApp” class  which is in the “myapp” folder will have the “myapp” namespace. The full name of the class will be “\myapp\MyApp“.

– The “AppSetup” class which is located in the “myapp/setup” folder will have the “myapp\setup” namespace. The full name of the class will be “\myapp\setup\AppSetup“.

1. Main class of the application

Myapp.php
<?php
namespace myapp;

use muuska\project\AbstractApplication;
use muuska\util\App;
use muuska\project\constants\SubAppName;

class MyApp extends AbstractApplication
{
    protected function registerMainDAOSources(){
        parent::registerMainDAOSources();
        $this->registerDaoSource(App::daos()->createPDOSourceFromConfiguration());
    }
    
    protected function createSubProject($subAppName){
        if($subAppName === SubAppName::FRONT_OFFICE){
            return new FrontSubApplication($subAppName, $this);
        }
    }
    
    protected function createAppSetup()
    {
        return new \myapp\setup\AppSetup($this);
    }
}

 

a. The registerMainDAOSources method

Used to record the available data access sources.

b. The createSubProject method

Allows you to create the instance of the subapplication.

c. the createAppSetup method

Allows you to create the application configuration.

 

2. The setup class

AppSetup.php
<?php
namespace myapp\setup;

use muuska\project\setup\AbstractProjectSetup;

class AppSetup extends AbstractProjectSetup
{
    public function __construct(\muuska\project\Application $application){
        $this->project = $application;
    }
}

 

3. The class of the sub-application

 

FrontSubApplication.php
<?php
namespace myapp;

use muuska\project\AbstractSubApplication;

class FrontSubApplication extends AbstractSubApplication
{
    
}