Skip to content

Commit 720f88b

Browse files
committed
Fix the setup process by adding config template
1 parent ac66791 commit 720f88b

File tree

2 files changed

+158
-4
lines changed

2 files changed

+158
-4
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?php
2+
/**
3+
* application.config.php
4+
*
5+
* Main application configuration parameters
6+
* You can change those values according to your application environment.
7+
*
8+
* @filesource application.config.php
9+
* @author Rosario Carvello <rosario.carvello@gmail.com>
10+
* @version GIT:v1.0.0
11+
* @copyright (c) 2016 Rosario Carvello <rosario.carvello@gmail.com> - All rights reserved. See License.txt file
12+
* @license BSD Clause 3 License
13+
* @license https://opensource.org/licenses/BSD-3-Clause This software is distributed under BSD-3-Clause Public License
14+
*/
15+
16+
/**
17+
* Defines the constants for MySQL database connection parameters.
18+
*/
19+
20+
/**
21+
* MySQL Host
22+
*/
23+
define("DBHOST", "{DB_HOST}");
24+
25+
/**
26+
* MySQL User
27+
*/
28+
define("DBUSER", "{DB_USER}");
29+
30+
/**
31+
* MySQL Password
32+
*/
33+
define("DBPASSWORD", "{DB_PASSWORD}");
34+
35+
/**
36+
* MySQL Database
37+
*/
38+
define("DBNAME", "{DB_NAME}");
39+
40+
/**
41+
* MySQL Port
42+
*/
43+
define('DBPORT', '{DB_PORT}');
44+
45+
/**
46+
* Defines a constant for site URL
47+
* @note without the ending slash
48+
*/
49+
define("SITEURL", "http://localhost:8000");
50+
// Or HTTPS
51+
// define("SITEURL","https://YOUR_HOST/YOUR_APP");
52+
53+
/**
54+
* Defines a constant for the default controller
55+
* @note use URL like notation for mapping a Controller named with a PascalCase notation
56+
*/
57+
define("DEFAULT_CONTROLLER", "index");
58+
59+
/**
60+
* Defines a constant for indicating the default login controller
61+
* You can use URL notation for specifying your custom Controller
62+
*/
63+
define("DEFAULT_LOGIN_PAGE", "common/login");
64+
65+
/**
66+
* Date formats:
67+
* @note HTML5 date format is like 2016/01/20 - aaaa/mm/dd
68+
*/
69+
70+
/**
71+
* Defines a constant for the transformation of the date format of all
72+
* date fields fetched from mysql tables
73+
* You may change this value according to your language format.
74+
* For more information read the MySQL specifications for date format
75+
* Most used format: define("FETCHED_DATE_FORMAT","d/m/Y");
76+
*/
77+
define("FETCHED_DATE_FORMAT", "Y-m-d");
78+
79+
/**
80+
* Defines a constant for the transformation of the datetime format of all
81+
* datetime fields fetched from mysql tables.
82+
* You may change this value according to your language format.
83+
* For more information read the MySQL specifications for date format
84+
* Most used format: define("FETCHED_DATETIME_FORMAT","d/m/Y H:i:s");
85+
*
86+
*/
87+
define("FETCHED_DATETIME_FORMAT", "Y-m-d H:i:s");
88+
89+
/**
90+
* Defines a constant for interpreting of dates format used into all the
91+
* SQL statements for inserting or updating mysql date fields.
92+
* You may change this value according to your language format.
93+
* For more information read the MySQL specifications for date format
94+
* Most used format: define("STORED_DATE_FORMAT","%d/%m/%Y");
95+
*/
96+
define("STORED_DATE_FORMAT", "%Y-%m-%d");
97+
98+
/**
99+
* Defines a constant for interpreting of datetime format used into all the
100+
* SQL statements for inserting or updating mysql datetime fields.
101+
* You may change this value according to your language format.
102+
* For more information read the MySQL specifications for date format
103+
* Most used format: define("STORED_DATETIME_FORMAT","%d/%m/%Y %H:%i:%s");
104+
*/
105+
define("STORED_DATETIME_FORMAT", "%Y-%m-%d %H:%i:%s");
106+
107+
/**
108+
* Instructs framework if MYSQL uses FULL_GROUP_BY sql mode
109+
* On MySQL > 5.7 FULL_GROUP_BY is enabled by default
110+
* If on your MySQL FULL_GROUP_BY is ON set it to true else false
111+
*/
112+
define("MYSQL_MODE_FULL_GROUP_BY", true);
113+
114+
115+
/**
116+
* Defines a constant for a temporary folder
117+
*/
118+
define("APP_TEMP_PATH", "D:\\gitmvc\\temp");
119+
120+
121+
/** TODO
122+
* Outuput charset
123+
*/
124+
define("CHARSET", "UTF-8");
125+
126+
/** TODO
127+
* Shows MVC Assembly debug information
128+
*/
129+
define("SHOW_ASSEMBLY_DEBUG_INFO", true);
130+
131+
132+
/**
133+
* Globals Placeholders
134+
*/
135+
include_once("globals.config.php");

setup-config.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,33 @@ function getVersion($cmd)
112112
return $returnVar === 0 ? $output[0] : false;
113113
}
114114

115+
// --------------
116+
// Initialization
117+
// --------------
118+
119+
$templateFile = __DIR__ . '/application.config.template.php';
120+
$configFile = __DIR__ . '/application.config.php';
121+
$sqlFile = __DIR__ . "/sql/mrp.sql";
122+
123+
if (!file_exists($templateFile)) {
124+
echo "\033[0;31m Template file not found: application.config.template.php\033[0m\n";
125+
exit(1);
126+
}
127+
128+
if (!copy($templateFile, $configFile)) {
129+
echo "\033[0;31m Failed to initialize application.config.php from template.\033[0m\n";
130+
exit(1);
131+
}
132+
133+
echo "\033[0;36m File application.config.php reinitialized from template.\033[0m\n\n";
134+
135+
115136

116137
// -------------------------
117138
// 1. Checking dependencies
118139
// -------------------------
119140

141+
120142
echo "Checking dependencies...\n";
121143

122144
$phpVersion = getVersion("php");
@@ -143,16 +165,13 @@ function getVersion($cmd)
143165
// 2. Configuration
144166
// -------------------------
145167

146-
$configFile = __DIR__ . "/config/application.config.php";
147-
$sqlFile = __DIR__ . "/sql/mrp.sql";
148-
149168
// get the project name (current folder)
150169
$projectName = basename(getcwd());
151170

152171
$placeholders = [
153172
"DB_HOST" => "localhost",
154173
"DB_USER" => "root",
155-
"DB_PASSWORD" => "",
174+
"DB_PASSWORD" => "root",
156175
"DB_NAME" => strtolower($projectName), // default: project name (current directory)
157176
"DB_PORT" => "3306"
158177
];

0 commit comments

Comments
 (0)