mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 08:34:11 +03:00
Use YAML for the core configurations
This commit is contained in:
parent
99a4ca6192
commit
3bb795a793
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@ src/absent_*
|
|||||||
src/release*
|
src/release*
|
||||||
|
|
||||||
# Do not index actual configuration files
|
# Do not index actual configuration files
|
||||||
src/mibew/configs/config.php
|
src/mibew/configs/config.yml
|
||||||
src/tests/server_side/mibew/libs/config.php
|
src/tests/server_side/mibew/libs/config.php
|
||||||
|
|
||||||
# Do not index avatars
|
# Do not index avatars
|
||||||
|
@ -13,8 +13,8 @@ INSTALLATION
|
|||||||
2. Upload all the files contained in this archive (retaining the directory structure) into created folder.
|
2. Upload all the files contained in this archive (retaining the directory structure) into created folder.
|
||||||
Be sure to chmod the mibew folder to 755 and the install folder to 644.
|
Be sure to chmod the mibew folder to 755 and the install folder to 644.
|
||||||
3. Add a MySQL database with the name 'mibew'
|
3. Add a MySQL database with the name 'mibew'
|
||||||
4. Copy /mibew/configs/default_config.php to /mibew/configs/config.php
|
4. Copy /mibew/configs/default_config.yml to /mibew/configs/config.yml
|
||||||
5. Edit /mibew/configs/config.php to the information needed to connect to the database
|
5. Edit /mibew/configs/config.yml to the information needed to connect to the database
|
||||||
6. Using your web browser visit http://<yourdomain>/mibew/install/ and
|
6. Using your web browser visit http://<yourdomain>/mibew/install/ and
|
||||||
hit 'Create tables'
|
hit 'Create tables'
|
||||||
7. Remove /mibew/install/ directory from your server
|
7. Remove /mibew/install/ directory from your server
|
||||||
@ -32,11 +32,11 @@ The owner should have all rights on the folder /mibew/files/avatar
|
|||||||
|
|
||||||
UPDATE
|
UPDATE
|
||||||
|
|
||||||
1. Backup your /mibew/configs/config.php
|
1. Backup your /mibew/configs/config.yml
|
||||||
2. Backup your /mibew/files/avatar folder.
|
2. Backup your /mibew/files/avatar folder.
|
||||||
3. Delete the items in the mibew folder on the server.
|
3. Delete the items in the mibew folder on the server.
|
||||||
4. Upload all the files contained in the downloaded archive (retaining the directory structure) into mibew folder.
|
4. Upload all the files contained in the downloaded archive (retaining the directory structure) into mibew folder.
|
||||||
5. Re-edit the MySQL database settings you config.php
|
5. Re-edit the MySQL database settings you config.yml
|
||||||
6. Visit http://<yourdomain>/mibew/install/ and follow the instructions to update database (if needed).
|
6. Visit http://<yourdomain>/mibew/install/ and follow the instructions to update database (if needed).
|
||||||
7. Remove /mibew/install/ directory from your server
|
7. Remove /mibew/install/ directory from your server
|
||||||
8. Restore contents of /mibew/files/avatar folder.
|
8. Restore contents of /mibew/files/avatar folder.
|
@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright 2005-2014 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IMPORTANT: Before install mibew copy this file to config.php and fill
|
|
||||||
* it with your own settings!
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Application path on server
|
|
||||||
*/
|
|
||||||
$mibewroot = "/mibew";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MySQL Database parameters
|
|
||||||
*/
|
|
||||||
$mysqlhost = "";
|
|
||||||
$mysqldb = "";
|
|
||||||
$mysqllogin = "";
|
|
||||||
$mysqlpass = "";
|
|
||||||
$mysqlprefix = "";
|
|
||||||
|
|
||||||
$use_persistent_connection = false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mailbox
|
|
||||||
*/
|
|
||||||
$mibew_mailbox = "mibew@yourdomain.com";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Locales
|
|
||||||
*/
|
|
||||||
$home_locale = "en"; /* native name will be used in this locale */
|
|
||||||
$default_locale = "en"; /* if user does not provide known lang */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Plugins
|
|
||||||
*/
|
|
||||||
$plugins_list = array();
|
|
||||||
|
|
||||||
/* Exapmle of plugins configuration
|
|
||||||
$plugins_list[] = array(
|
|
||||||
'name' => 'plugin_name',
|
|
||||||
'config' => array(
|
|
||||||
'weight' => 100,
|
|
||||||
'some_configurable_value' => 'value'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
*/
|
|
39
src/mibew/configs/default_config.yml
Normal file
39
src/mibew/configs/default_config.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# IMPORTANT: Before install mibew copy this file to config.yml and fill it with
|
||||||
|
# your own settings!
|
||||||
|
|
||||||
|
|
||||||
|
# Application path on server
|
||||||
|
mibew_root: /mibew
|
||||||
|
|
||||||
|
# MySQL Database parameters
|
||||||
|
database:
|
||||||
|
host: ""
|
||||||
|
db: ""
|
||||||
|
login: ""
|
||||||
|
pass: ""
|
||||||
|
tables_prefix: ""
|
||||||
|
use_persistent_connection: false
|
||||||
|
|
||||||
|
# Mailbox
|
||||||
|
mailbox: mibew@yourdomain.com
|
||||||
|
|
||||||
|
# Locales
|
||||||
|
## Native name will be used in this locale
|
||||||
|
home_locale: en
|
||||||
|
## If user does not provide known lang
|
||||||
|
default_locale: en
|
||||||
|
|
||||||
|
# Plugins
|
||||||
|
plugins: []
|
||||||
|
|
||||||
|
## Exapmle of plugins configuration
|
||||||
|
# plugins:
|
||||||
|
# -
|
||||||
|
# name: "VendorName:PluginName"
|
||||||
|
# config:
|
||||||
|
# weight: 100
|
||||||
|
# some_configurable_value: value
|
||||||
|
# -
|
||||||
|
# name: "VendorName:AnotherPluginName"
|
||||||
|
# config:
|
||||||
|
# very_important_value: "$3.50"
|
@ -368,9 +368,9 @@ class Installer
|
|||||||
{
|
{
|
||||||
if ($real_base_path != MIBEW_WEB_ROOT) {
|
if ($real_base_path != MIBEW_WEB_ROOT) {
|
||||||
$this->errors[] = getlocal(
|
$this->errors[] = getlocal(
|
||||||
"Please, check file {0}<br/>Wrong value of \$mibewroot variable, should be \"{1}\"",
|
"Please, check file {0}<br/>Wrong value of \"mibew_root\" variable, should be \"{1}\"",
|
||||||
array(
|
array(
|
||||||
$real_base_path . "/configs/config.php",
|
$real_base_path . "/configs/config.yml",
|
||||||
$real_base_path
|
$real_base_path
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -699,7 +699,7 @@ class Installer
|
|||||||
);
|
);
|
||||||
} catch(\PDOException $e) {
|
} catch(\PDOException $e) {
|
||||||
$this->errors[] = getlocal(
|
$this->errors[] = getlocal(
|
||||||
"Could not connect. Please check server settings in config.php. Error: {0}",
|
"Could not connect. Please check server settings in config.yml. Error: {0}",
|
||||||
array($e->getMessage())
|
array($e->getMessage())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads system configurations.
|
* Loads system configurations.
|
||||||
*
|
*
|
||||||
@ -27,25 +29,8 @@ function load_system_configs()
|
|||||||
static $configs = null;
|
static $configs = null;
|
||||||
|
|
||||||
if (is_null($configs)) {
|
if (is_null($configs)) {
|
||||||
// Load and "parse" configs file. While configs are written in a php
|
$parser = new YamlParser();
|
||||||
// file include is the only option to load and parse them.
|
$configs = $parser->parse(file_get_contents(MIBEW_FS_ROOT . '/configs/config.yml'));
|
||||||
include(MIBEW_FS_ROOT . "/configs/config.php");
|
|
||||||
|
|
||||||
$configs = array(
|
|
||||||
'mibew_root' => $mibewroot,
|
|
||||||
'database' => array(
|
|
||||||
'host' => $mysqlhost,
|
|
||||||
'db' => $mysqldb,
|
|
||||||
'login' => $mysqllogin,
|
|
||||||
'pass' => $mysqlpass,
|
|
||||||
'tables_prefix' => $mysqlprefix,
|
|
||||||
'use_persistent_connection' => $use_persistent_connection,
|
|
||||||
),
|
|
||||||
'mailbox' => $mibew_mailbox,
|
|
||||||
'home_locale' => $home_locale,
|
|
||||||
'default_locale' => $default_locale,
|
|
||||||
'plugins' => $plugins_list,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $configs;
|
return $configs;
|
||||||
|
@ -27,7 +27,7 @@ define('LOCALE_COOKIE_NAME', 'mibew_locale');
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verified value of the $default_locale configuration parameter (see
|
* Verified value of the $default_locale configuration parameter (see
|
||||||
* "configs/default_config.php" for details)
|
* "configs/default_config.yml" for details)
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
'DEFAULT_LOCALE',
|
'DEFAULT_LOCALE',
|
||||||
@ -38,7 +38,7 @@ define(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verified value of the $home_locale configuration parameter (see
|
* Verified value of the $home_locale configuration parameter (see
|
||||||
* "configs/default_config.php" for details)
|
* "configs/default_config.yml" for details)
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
'HOME_LOCALE',
|
'HOME_LOCALE',
|
||||||
|
@ -20,6 +20,16 @@
|
|||||||
*/
|
*/
|
||||||
define('MIBEW_FS_ROOT', dirname(dirname(__FILE__)));
|
define('MIBEW_FS_ROOT', dirname(dirname(__FILE__)));
|
||||||
|
|
||||||
|
// Initialize classes autoloading
|
||||||
|
require_once(MIBEW_FS_ROOT . '/libs/classes/Mibew/Autoloader.php');
|
||||||
|
Mibew\Autoloader::register(MIBEW_FS_ROOT . '/libs/classes');
|
||||||
|
|
||||||
|
// Automatically load plugins
|
||||||
|
Mibew\Autoloader::register(MIBEW_FS_ROOT . '/plugins');
|
||||||
|
|
||||||
|
// Initialize external dependencies
|
||||||
|
require_once(MIBEW_FS_ROOT . '/vendor/autoload.php');
|
||||||
|
|
||||||
// Load system configurations
|
// Load system configurations
|
||||||
require_once(MIBEW_FS_ROOT . '/libs/common/configurations.php');
|
require_once(MIBEW_FS_ROOT . '/libs/common/configurations.php');
|
||||||
$configs = load_system_configs();
|
$configs = load_system_configs();
|
||||||
@ -41,16 +51,6 @@ define('MIBEW_WEB_ROOT', $mibewroot);
|
|||||||
// Include system constants file
|
// Include system constants file
|
||||||
require_once(MIBEW_FS_ROOT . '/libs/common/constants.php');
|
require_once(MIBEW_FS_ROOT . '/libs/common/constants.php');
|
||||||
|
|
||||||
// Initialize classes autoloading
|
|
||||||
require_once(MIBEW_FS_ROOT . '/libs/classes/Mibew/Autoloader.php');
|
|
||||||
Mibew\Autoloader::register(MIBEW_FS_ROOT . '/libs/classes');
|
|
||||||
|
|
||||||
// Automatically load plugins
|
|
||||||
Mibew\Autoloader::register(MIBEW_FS_ROOT . '/plugins');
|
|
||||||
|
|
||||||
// Initialize external dependencies
|
|
||||||
require_once(MIBEW_FS_ROOT . '/vendor/autoload.php');
|
|
||||||
|
|
||||||
// Include common libs
|
// Include common libs
|
||||||
require_once(MIBEW_FS_ROOT . '/libs/common/verification.php');
|
require_once(MIBEW_FS_ROOT . '/libs/common/verification.php');
|
||||||
require_once(MIBEW_FS_ROOT . '/libs/common/locale.php');
|
require_once(MIBEW_FS_ROOT . '/libs/common/locale.php');
|
||||||
@ -73,7 +73,7 @@ if (is_secure_request()) {
|
|||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if (function_exists("date_default_timezone_set")) {
|
if (function_exists("date_default_timezone_set")) {
|
||||||
// TODO try to get timezone from config.php/session etc.
|
// TODO try to get timezone from config.yml/session etc.
|
||||||
// autodetect timezone
|
// autodetect timezone
|
||||||
@date_default_timezone_set(function_exists("date_default_timezone_get") ? @date_default_timezone_get() : "GMT");
|
@date_default_timezone_set(function_exists("date_default_timezone_get") ? @date_default_timezone_get() : "GMT");
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ if (!installation_in_progress()) {
|
|||||||
|
|
||||||
if (!empty($configs['plugins'])) {
|
if (!empty($configs['plugins'])) {
|
||||||
// A list of plugins is defined in $plugins_list variable in
|
// A list of plugins is defined in $plugins_list variable in
|
||||||
// configs/config.php
|
// configs/config.yml
|
||||||
\Mibew\Plugin\Manager::loadPlugins($configs['plugins']);
|
\Mibew\Plugin\Manager::loadPlugins($configs['plugins']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user