Skip to content

Commit 1b2d063

Browse files
author
Fredrick Peter
committed
update
1 parent f2aac1c commit 1b2d063

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
.gitignore
1212
.user.ini
1313
composer.lock
14-
test.php
14+
test.php
15+
init.php

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ was pretty tough. So i decided to create a much more easier way of communicating
1919
* [Installation](#installation)
2020
* [Instantiate](#instantiate)
2121
* [Init.php File](#init.php-file)
22+
* [BootLoader](#bootLoader)
2223
* [Database Connection](#database-connection)
2324
* [Database Disconnect](#database-disconnect)
2425
* [App Debug ENV](#app-debug-env)
@@ -171,6 +172,19 @@ autoloader_start([
171172
| Everywhere in your project, instead of the `vendor/autoload.php` file. |
172173
| This is totally optional. |
173174

175+
## BootLoader
176+
- If you do not want to include or use the `Init.php` file
177+
- All you need do is call the bootloader, to start your application.
178+
179+
```
180+
use builder\Database\Capsule\AppManager;
181+
182+
AppManager::bootLoader();
183+
184+
or
185+
186+
app_manager()->bootLoader();
187+
```
174188

175189
## Database Connection
176190
- You have the options to connect to multiple database
@@ -1236,6 +1250,7 @@ class Post extends Model{
12361250
| env() | Same as `$db->env()` |
12371251
| env_update() | Same as `Env::updateENV` method |
12381252
| env_orm() | Return instance of `(new Env)` class |
1253+
| app_manager() | Return instance of `(new AppManager)` class |
12391254
| import() | Return instance of `(new DBImport)->import()` method |
12401255
| migration() | Return instance of `(new Migration)` class |
12411256
| schema() | Return instance of `(new Schema)` class |

src/Capsule/AppManager.php

Lines changed: 12 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\DB;
8+
use builder\Database\Env;
89
use builder\Database\AutoLoader;
910
use builder\Database\Capsule\FileCache;
1011
use builder\Database\Capsule\DebugManager;
@@ -68,7 +69,7 @@ public static function envDummy()
6869
*
6970
* @return string
7071
*/
71-
public static function generate($length = 32)
72+
private static function generate($length = 32)
7273
{
7374
$randomBytes = random_bytes($length);
7475
$appKey = 'base64:' . rtrim(strtr(base64_encode($randomBytes), '+/', '-_'), '=');
@@ -84,6 +85,16 @@ public static function generate($length = 32)
8485
return $appKey;
8586
}
8687

88+
/**
89+
* Re-generate a new app KEY
90+
*
91+
* @return void
92+
*/
93+
public static function regenerate()
94+
{
95+
Env::updateENV('APP_KEY', self::generate(), false);
96+
}
97+
8798
/**
8899
* Starting our Application
89100
*

src/Capsule/FileCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FileCache
1414
* @param string $path
1515
* @return void
1616
*/
17-
public static function setCachePath(string $path): void
17+
public static function setCachePath(string $path = "cache"): void
1818
{
1919
// if \storage folder not found
2020
$path = storage_path($path);

src/helpers.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use builder\Database\AutoLoader;
88
use builder\Database\AutoloadRegister;
99
use builder\Database\Migrations\Schema;
10+
use builder\Database\Capsule\AppManager;
1011
use builder\Database\Migrations\Migration;
1112

1213
if (! function_exists('autoloader_start')) {
@@ -143,7 +144,7 @@ function env_update(?string $key = null, string|bool $value = null, ?bool $allow
143144

144145
if (! function_exists('env_orm')) {
145146
/**
146-
* Get Dot Env
147+
* Get Instance of Dot Env
147148
*
148149
* @return \builder\Database\Env
149150
*/
@@ -153,6 +154,18 @@ function env_orm()
153154
}
154155
}
155156

157+
if (! function_exists('app_manager')) {
158+
/**
159+
* Get Instance of AppManager
160+
*
161+
* @return \builder\Database\Capsule\AppManager
162+
*/
163+
function app_manager()
164+
{
165+
return (new AppManager);
166+
}
167+
}
168+
156169
if (! function_exists('import')) {
157170
/**
158171
* Database Importation
@@ -247,6 +260,7 @@ function asset_config(?string $base_path = null, ?bool $cache = true)
247260
* - showing | string | Change the letter of `Showing`
248261
* - of | string | Change the letter `of`
249262
* - results | string | Change the letter `results`
263+
* - buttons | int | Numbers of pagination links to generate. Default is 5 and limit is 20
250264
*
251265
* @return void
252266
*/

0 commit comments

Comments
 (0)