public function database(Container $application){
             
        $config     = $this->config;

        //Stores all user information in the database;
        $dbName = $application->input->getString("dbname", "", "post");
        $dbPass = $application->input->getString("dbpassword", "", "post");
        $dbHost = $application->input->getString("dbhost", "", "post");
        $dbPref = $application->input->getString("dbtableprefix", "", "post");
        $dbUser = $application->input->getString("dbusername", "", "post");
        $dbDriver = $application->input->getString("dbdriver","MySQLi", "post");
        $dbPort = $application->input->getInt("dbport","", "post");
        
        if(empty($dbName)){
            throw new \Exception(t("Database Name is required to proceed."));
            return false;
        }
        if(empty($dbDriver)){
            throw new \Exception(t("Database Driver Type is required to proceed."));
            return false;
        }
        if(empty($dbUser)){
            throw new \Exception(t("Database username is required to proceed"));
            return false;
        }
        if(empty($dbHost)){
            throw new \Exception(t("Please provide a link to your database host. If using SQLite, provide a path to the SQLite database as host"));
            return false;
        }
        $config->set("setup.database.host", $dbHost );
        $config->set("setup.database.prefix", $dbPref );
        $config->set("setup.database.user", $dbUser );
        $config->set("setup.database.password", $dbPass );
        $config->set("setup.database.name", $dbName );
        $config->set("setup.database.driver", strtolower($dbDriver ) );
        $config->set("setup.database.port", intval($dbPort) );


        //Try connect to the database with these details?
        try{

            $application->createInstance("database",
                [
                    $application->config->get("setup.database.driver"), //get the database driver
                    $application->config->get("setup.database") //get all the database options and pass to the driver
                ]
            );

        } catch (Exception $exception) {


           //@TODO do something with this exception;

            return false;

        }


        //@TODO run the install.sql script on the connected database
         $schema = new Schema();


         //print_r($schema::$database);
        if(!$schema->createTables( $application->database )){

            echo "wtf";

            return false;
        }

        //generate encryption key
        $encryptor  = $this->encryptor;
        $encryptKey = $encryptor->generateKey( time().getRandomString(5) );

        $config->set("setup.encrypt.key", $encryptKey );

        if(!$config->saveParams() ){

            throw new Exception("could not save config");

            return false;
        }
        return true;
    }
public function database(Container $application){
             
        $config     = $this->config;

        //Stores all user information in the database;
        $dbName = $application->input->getString("dbname", "", "post");
        $dbPass = $application->input->getString("dbpassword", "", "post");
        $dbHost = $application->input->getString("dbhost", "", "post");
        $dbPref = $application->input->getString("dbtableprefix", "", "post");
        $dbUser = $application->input->getString("dbusername", "", "post");
        $dbDriver = $application->input->getString("dbdriver","MySQLi", "post");
        $dbPort = $application->input->getInt("dbport","", "post");
        
        if(empty($dbName)){
            throw new \Exception(t("Database Name is required to proceed."));
            return false;
        }
        if(empty($dbDriver)){
            throw new \Exception(t("Database Driver Type is required to proceed."));
            return false;
        }
        if(empty($dbUser)){
            throw new \Exception(t("Database username is required to proceed"));
            return false;
        }
        if(empty($dbHost)){
            throw new \Exception(t("Please provide a link to your database host. If using SQLite, provide a path to the SQLite database as host"));
            return false;
        }
        $config->set("setup.database.host", $dbHost );
        $config->set("setup.database.prefix", $dbPref );
        $config->set("setup.database.user", $dbUser );
        $config->set("setup.database.password", $dbPass );
        $config->set("setup.database.name", $dbName );
        $config->set("setup.database.driver", strtolower($dbDriver ) );
        $config->set("setup.database.port", intval($dbPort) );


        //Try connect to the database with these details?
        try{

            $application->createInstance("database",
                [
                    $application->config->get("setup.database.driver"), //get the database driver
                    $application->config->get("setup.database") //get all the database options and pass to the driver
                ]
            );

        } catch (Exception $exception) {


           //@TODO do something with this exception;

            return false;

        }


        //@TODO run the install.sql script on the connected database
         $schema = new Schema();


         //print_r($schema::$database);
        if(!$schema->createTables( $application->database )){

            echo "wtf";

            return false;
        }

        //generate encryption key
        $encryptor  = $this->encryptor;
        $encryptKey = $encryptor->generateKey( time().getRandomString(5) );

        $config->set("setup.encrypt.key", $encryptKey );

        if(!$config->saveParams() ){

            throw new Exception("could not save config");

            return false;
        }
        return true;
    }
public function database ( Container $ application ) { $ config = $ this -> config ; //Stores all user information in the database; $ dbName = $ application -> input -> getString ( "dbname" , "" , "post" ) ; $ dbPass = $ application -> input -> getString ( "dbpassword" , "" , "post" ) ; $ dbHost = $ application -> input -> getString ( "dbhost" , "" , "post" ) ; $ dbPref = $ application -> input -> getString ( "dbtableprefix" , "" , "post" ) ; $ dbUser = $ application -> input -> getString ( "dbusername" , "" , "post" ) ; $ dbDriver = $ application -> input -> getString ( "dbdriver" , "MySQLi" , "post" ) ; $ dbPort = $ application -> input -> getInt ( "dbport" , "" , "post" ) ; if ( empty ( $ dbName ) ) { throw new \ Exception ( t ( "Database Name is required to proceed." ) ) ; return false ; } if ( empty ( $ dbDriver ) ) { throw new \ Exception ( t ( "Database Driver Type is required to proceed." ) ) ; return false ; } if ( empty ( $ dbUser ) ) { throw new \ Exception ( t ( "Database username is required to proceed" ) ) ; return false ; } if ( empty ( $ dbHost ) ) { throw new \ Exception ( t ( "Please provide a link to your database host. If using SQLite, provide a path to the SQLite database as host" ) ) ; return false ; } $ config -> set ( "setup.database.host" , $ dbHost ) ; $ config -> set ( "setup.database.prefix" , $ dbPref ) ; $ config -> set ( "setup.database.user" , $ dbUser ) ; $ config -> set ( "setup.database.password" , $ dbPass ) ; $ config -> set ( "setup.database.name" , $ dbName ) ; $ config -> set ( "setup.database.driver" , strtolower ( $ dbDriver ) ) ; $ config -> set ( "setup.database.port" , intval ( $ dbPort ) ) ; //Try connect to the database with these details? try { $ application -> createInstance ( "database" , [ $ application -> config -> get ( "setup.database.driver" ) , //get the database driver $ application -> config -> get ( "setup.database" ) //get all the database options and pass to the driver ] ) ; } catch ( Exception $ exception ) { //@TODO do something with this exception; return false ; } //@TODO run the install.sql script on the connected database $ schema = new Schema ( ) ; //print_r($schema::$database); if ( ! $ schema -> createTables ( $ application -> database ) ) { echo "wtf" ; return false ; } //generate encryption key $ encryptor = $ this -> encryptor ; $ encryptKey = $ encryptor -> generateKey ( time ( ) . getRandomString ( 5 ) ) ; $ config -> set ( "setup.encrypt.key" , $ encryptKey ) ; if ( ! $ config -> saveParams ( ) ) { throw new Exception ( "could not save config" ) ; return false ; } return true ; }
Executes the installation

@return boolean
Executes the installation