4.8 KiB
4.8 KiB
##Getting started
This is an introduction how to setup a webpage with system
##Setup
Create a new git repository, initialize a submodule for system, check it out, create a folder named like your project, it will contain all project files, create a api.php, index.php, sai.php and config.php file. Dependent on what part of SYSTEM you want to use leave out api or index.
- D: system
- D: project
- F: api.php
- F: index.php
- F: sai.php
- F: config.php
File api.php - console of your webpage (jquery...):
<?php
require_once 'system/autoload.inc.php'; //SYSTEM Classes
require_once 'project/autoload.inc.php'; //Project Classes
require_once 'config.php';
SYSTEM\system::start($project_config);
\SYSTEM\system::include_ExceptionShortcut();
\SYSTEM\system::include_ResultShortcut();
\SYSTEM\system::register_errorhandler_dbwriter();
\SYSTEM\system::register_errorhandler_jsonoutput();
echo \SYSTEM\API\api::run('\SYSTEM\API\verify','api_project',array_merge($_POST,$_GET));
File index.php - Frontend of your webpage:
<?php
require_once 'system/autoload.inc.php'; //SYSTEM Classes
require_once 'project/autoload.inc.php'; //Project Classes
require_once 'config.php'; //Server config
SYSTEM\system::start($project_config);
\SYSTEM\system::include_ExceptionShortcut();
\SYSTEM\system::include_ResultShortcut();
\SYSTEM\system::register_errorhandler_dbwriter();
\SYSTEM\system::register_errorhandler_jsonoutput();
echo \SYSTEM\API\api::run('\SYSTEM\API\verify','page_project',array_merge($_POST,$_GET),1,false,true)->html();
File sai.php - Admin Interface:
<?php
require_once 'system/autoload.inc.php'; //SYSTEM Classes
require_once 'project/autoload.inc.php'; //Project Classes
require_once 'config.php'; //Server config
SYSTEM\system::start($project_config); //Start System time + config
SYSTEM\system::include_ExceptionShortcut(); //allow ERROR() instead of \SYSTEM\LOG\ERROR()
SYSTEM\system::include_ResultShortcut(); //allow JsonResult() instead of \SYSTEM\LOG\JsonResult()
SYSTEM\system::register_errorhandler_dbwriter(); //write errors to database (must be first errorhandler to register)
SYSTEM\system::register_errorhandler_jsonoutput(); //print errors as json to caller
require_once 'system/sai/autoload.inc.php'; //load sai system modules
require_once 'project/sai/autoload.inc.php'; //autoload sai project modules
require_once 'project/sai/register_modules.php'; //register sai project modules
$sai = new SYSTEM\SAI\saigui(); //Draw it
echo $sai->html();
File config.php - Your Server and Project config
<?php
$project_config=array( array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_ERRORREPORTING, E_ALL | E_STRICT),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL, 'http://www.project.eu/'),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEPATH, '/home/web/project/'),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_TYPE, SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_TYPE_MYS),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_HOST, '127.0.0.1'),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_PORT, ''),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_USER, 'dbuser'),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_PASSWORD, 'dbpw'),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_DBNAME, 'dbname'),
array(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_SYSTEMPATHREL, 'system/'),
array(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE, 'mojotrollz - Admin Area'),
array(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_COPYRIGHT, '<a href="http://www.project.eu/" target="_blank">mojotrollz</a>, © WebCraft Media 2013'),
array(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS, array('deDE', 'enUS')),
array(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG, 'enUS'));