Skip to content

Commit 63da417

Browse files
author
Fredrick Peter
committed
Dumper and Code Model Overall Speed increased
1 parent c4d9765 commit 63da417

File tree

15 files changed

+192
-194
lines changed

15 files changed

+192
-194
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/demo
66
/database
77
/storage
8+
/path
89
.env
910
.htaccess
1011
.gitignore

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ $db->table('users')
210210
|-------------------|-----------|-----------------------|
211211
| DRIVER_NAME | string | mysql |
212212
| APP_DEBUG | boolean | true |
213-
| APP_DEBUG_BG | string | Default value is `default` and other color \| `main` \| `dark` \| `red` \| `blue` |
213+
| APP_DEBUG_BG | string | Default value is `dark` and other color \| `light` |
214214
| DB_HOST | string | `localhost` |
215215
| DB_USERNAME | string | |
216216
| DB_PASSWORD | string | |
@@ -1463,9 +1463,7 @@ class PostClass extends DB{
14631463

14641464
| function | Description |
14651465
|-----------|-----------------|
1466-
| ddump | Custom made error dump |
1467-
| dump | Dump error handling |
1468-
| dd | Dump and Die - Error handling |
1466+
| dd | Dump or Die - Error handling |
14691467

14701468

14711469
## Error Status

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"require": {
1919
"php": ">=7.2",
2020
"vlucas/phpdotenv": "^5.3",
21-
"symfony/var-dumper": "^4.0 || ^5.0 || ^6.0",
22-
"ezyang/htmlpurifier": "^4.16.0"
21+
"ezyang/htmlpurifier": "^4.16.0",
22+
"tracy/tracy": "^2.9"
2323
},
2424
"config": {
2525
"platform": {

src/Capsule/AppManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace builder\Database\Capsule;
66

77
use builder\Database\Constants;
8+
use builder\Database\Capsule\Manager;
89

910

1011
class AppManager extends Constants{
@@ -29,7 +30,7 @@ static public function envDummy()
2930
APP_ENV=local
3031
APP_KEY='. self::generateAppKey() .'
3132
APP_DEBUG=true
32-
APP_DEBUG_BG=default
33+
APP_DEBUG_BG='. Manager::$default_bg .'
3334
SITE_EMAIL=
3435
3536
DRIVER_NAME=mysql

src/Capsule/Manager.php

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ class Manager extends Constants{
3939
'view' => 'simple',
4040
];
4141

42+
/**
43+
* @var array
44+
*/
45+
static public $pagination_views = [
46+
'bootstrap' => 'bootstrap',
47+
'simple' => 'simple',
48+
];
49+
4250
/**
4351
* @var array
4452
*/
@@ -65,14 +73,19 @@ class Manager extends Constants{
6573
'latin1_bin',
6674
];
6775

68-
/**
76+
/**
6977
* @var array
7078
*/
7179
static private $charsets = [
7280
'utf8mb4',
7381
'utf8',
7482
'latin1',
7583
];
84+
85+
/**
86+
* @var string
87+
*/
88+
static public $default_bg = 'dark';
7689

7790
/**
7891
* Initilize and Set the Database Configuration on constructor
@@ -91,18 +104,18 @@ class Manager extends Constants{
91104
*/
92105
static public function initConfiguration(?array $options = [])
93106
{
94-
$defaultOption = [
95-
'APP_DEBUG' => $options['APP_DEBUG'] ?? true,
96-
'APP_DEBUG_BG' => $options['APP_DEBUG_BG'] ?? 'default',
97-
'DRIVER_NAME' => $options['DRIVER_NAME']?? 'mysql',
98-
'DB_HOST' => $options['DB_HOST'] ?? 'localhost',
99-
'DB_DATABASE' => $options['DB_DATABASE'] ?? '',
100-
'DB_USERNAME' => $options['DB_USERNAME'] ?? '',
101-
'DB_PASSWORD' => $options['DB_PASSWORD'] ?? '',
102-
'DB_PORT' => $options['DB_PORT'] ?? 3306,
103-
'DB_COLLATION' => $options['DB_COLLATION'] ?? 'utf8mb4_unicode_ci',
104-
'DB_CHARSET' => $options['DB_CHARSET'] ?? 'utf8mb4',
105-
];
107+
$defaultOption = array_merge([
108+
'APP_DEBUG' => true,
109+
'APP_DEBUG_BG' => self::$default_bg,
110+
'DRIVER_NAME' => 'mysql',
111+
'DB_HOST' => 'localhost',
112+
'DB_DATABASE' => '',
113+
'DB_USERNAME' => '',
114+
'DB_PASSWORD' => '',
115+
'DB_PORT' => 3306,
116+
'DB_COLLATION' => 'utf8mb4_unicode_ci',
117+
'DB_CHARSET' => 'utf8mb4',
118+
], $options);
106119

107120
// get accepted data
108121
$defaultOption['DB_COLLATION'] = self::findCollation($defaultOption['DB_COLLATION']);
@@ -171,7 +184,7 @@ static public function getConfig($key = 'DB_HOST')
171184
{
172185
$data = [
173186
'APP_DEBUG' => defined('APP_DEBUG') ? APP_DEBUG : true,
174-
'APP_DEBUG_BG' => defined('APP_DEBUG_BG') ? APP_DEBUG_BG : 'default',
187+
'APP_DEBUG_BG' => defined('APP_DEBUG_BG') ? APP_DEBUG_BG : self::$default_bg,
175188
'DRIVER_NAME' => defined('DRIVER_NAME') ? DRIVER_NAME : 'mysql',
176189
'DB_HOST' => defined('DB_HOST') ? DB_HOST : 'localhost',
177190
'DB_DATABASE' => defined('DB_DATABASE') ? DB_DATABASE : null,
@@ -218,7 +231,7 @@ static public function setHeaders()
218231
flush();
219232

220233
// Exit with response 404
221-
exit();
234+
exit(1);
222235
}
223236

224237
/**
@@ -588,31 +601,4 @@ static public function convertOptimizeErrorTemp($result)
588601
];
589602
}
590603

591-
/**
592-
* Create String Template of all possible error
593-
* @param Exception $exception
594-
*
595-
* @return string
596-
*/
597-
static public function convertExceptionErrorTemp(Exception $exception)
598-
{
599-
$temp = '';
600-
$getTrace = ($exception)->getTrace();
601-
unset($getTrace[0]);
602-
603-
foreach($getTrace as $key => $error){
604-
if(!in_array($error['function'], self::$disallow_method)){
605-
$temp .= "
606-
<<\\File>> {$error['file']}
607-
<<\\Line>> {$error['line']}
608-
<<\\Function>> {$error['function']}
609-
<<\\Class>> {$error['class']}
610-
====================================================
611-
";
612-
}
613-
}
614-
615-
return $temp;
616-
}
617-
618604
}

src/DB.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
namespace builder\Database;
1414

15+
use builder\Database\Query\MySqlExec;
1516
use builder\Database\Schema\Insertion;
1617

1718
class DB extends Insertion{
@@ -35,5 +36,8 @@ public function __construct(?array $options = []) {
3536
$this->configPagination($options);
3637
}
3738
}
39+
40+
// open default logger
41+
(new MySqlExec)->autoStartDebugger();
3842
}
3943
}

src/Dummy/dummyHtaccess.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@
22
# Start Engine
33
RewriteEngine On
44

5-
# Cache-busting rule
6-
RewriteCond %{QUERY_STRING} !cache-buster [NC]
7-
RewriteRule \.(php|html)$ %{REQUEST_URI}?cache-buster=%{TIME_SEC} [L]
8-
9-
# Disable caching for PHP files
10-
RewriteCond %{ENV:REDIRECT_NO_CACHE} !^$
11-
RewriteRule \.php$ - [E=NO_CACHE:1]
12-
135
# Define additional rules below
146
#
15-
167

178
# Cache control headers
189
<IfModule mod_headers.c>
@@ -37,15 +28,6 @@
3728
<filesMatch "\.(x?php)$">
3829
Header set Cache-Control "private, must-revalidate"
3930
</filesMatch>
40-
41-
# Disable caching for PHP files when NO_CACHE is defined
42-
<IfDefine NO_CACHE>
43-
<FilesMatch "\.php$">
44-
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
45-
Header set Pragma "no-cache"
46-
Header set Expires "Thu, 01 Jan 1970 00:00:00 GMT"
47-
</FilesMatch>
48-
</IfDefine>
4931
</IfModule>
5032

5133
# Mod security

src/EnvAutoLoad.php

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace builder\Database;
66

77
use builder\Database\DB;
8-
use builder\Database\Capsule\Manager;
98
use builder\Database\Schema\EnvOrm;
9+
use builder\Database\Capsule\Manager;
1010

1111
class EnvAutoLoad{
1212

@@ -17,7 +17,7 @@ class EnvAutoLoad{
1717
*
1818
* @param array $options
1919
* path \Path to .env file
20-
* bg \dump background color (default | main | dark | red | blue)
20+
* bg \dump background color (light | dark)
2121
*
2222
* @return void
2323
*/
@@ -28,10 +28,10 @@ static public function start(?array $options = [])
2828
| Create default path and bg for errors
2929
|--------------------------------------------------------------------------
3030
*/
31-
$default = [
32-
'path' => $options['path'] ?? null,
33-
'bg' => $options['bg'] ?? 'default',
34-
];
31+
$default = array_merge([
32+
'path' => null,
33+
'bg' => Manager::$default_bg,
34+
], $options);
3535

3636
/*
3737
|--------------------------------------------------------------------------
@@ -153,19 +153,26 @@ static public function configPagination(?array $options = [])
153153
|--------------------------------------------------------------------------
154154
*/
155155
$text = Manager::$pagination_text;
156-
$default = [
157-
'allow' => $options['allow'] ?? 'disallow',
158-
'class' => $options['class'] ?? null,
159-
'view' => in_array($options['view'] ?? null, ['bootstrap', 'simple']) ? $options['view'] : $text['view'],
160-
'first' => $options['first'] ?? $text['first'],
161-
'last' => $options['last'] ?? $text['last'],
162-
'next' => $options['next'] ?? $text['next'],
163-
'prev' => $options['prev'] ?? $text['prev'],
164-
'span' => $options['span'] ?? $text['span'],
165-
'showing' => $options['showing'] ?? $text['showing'],
166-
'of' => $options['of'] ?? $text['of'],
167-
'results' => $options['results'] ?? $text['results'],
168-
];
156+
$getViews = Manager::$pagination_views;
157+
158+
$default = array_merge([
159+
'allow' => 'disallow',
160+
'class' => null,
161+
'view' => null,
162+
'first' => $text['first'],
163+
'last' => $text['last'],
164+
'next' => $text['next'],
165+
'prev' => $text['prev'],
166+
'span' => $text['span'],
167+
'showing' => $text['showing'],
168+
'of' => $text['of'],
169+
'results' => $text['results'],
170+
], $options);
171+
172+
// get actual view
173+
$default['view'] = in_array($default['view'], $getViews)
174+
? $options['view']
175+
: $text['view'];
169176

170177
/*
171178
|--------------------------------------------------------------------------

src/Migrations/Traits/SchemaConfigurationTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ protected function createColumnDefinition(?array $options)
9191
{
9292
// array merge
9393
$options = array_merge($options, [
94-
'name' => $options['name'] ?? '',
95-
'type' => $options['type'] ?? '',
96-
'length' => $options['length'] ?? null,
97-
'default' => $options['default'] ?? null,
98-
'nullable' => $options['nullable'] ?? false,
99-
]);
94+
'name' => '',
95+
'type' => '',
96+
'length' => null,
97+
'default' => null,
98+
'nullable' => false,
99+
], $options);
100100

101101
// create default string
102102
$getType = $this->getColumnType($options['type']);

0 commit comments

Comments
 (0)