Skip to content

Commit 093adce

Browse files
author
Fredrick Peter
committed
ServerTrait Error Fix
1 parent b873387 commit 093adce

File tree

4 files changed

+43
-23
lines changed

4 files changed

+43
-23
lines changed

README.md

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ was pretty tough. So i decided to create a much more easier way of communicating
9494
* [Drop Migration](#drop-migration)
9595
* [Drop Table](#drop-table)
9696
* [Drop Column](#drop-column)
97-
* [Get Database Config Data](#get-database-config-data)
97+
* [Get Database Config](#get-database-config)
9898
* [Get Database Connection](#get-database-connection)
99+
* [Get Database Name](#get-database-name)
100+
* [Get Database PDO](#get-database-pdo)
101+
* [Get Database TablePrefix](#get-database-tableprefix)
99102
* [Database Import](#database-import)
100103
* [Update Env Variable](#update-env-variable)
101104
* [Env Servers](#Env-servers)
@@ -119,7 +122,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
119122
**Step 1** — update your `composer.json`:
120123
```composer.json
121124
"require": {
122-
"peterson/database": "^4.3.5"
125+
"peterson/database": "^4.3.6"
123126
}
124127
```
125128

@@ -140,28 +143,26 @@ composer require peterson/database
140143
require_once __DIR__ . '/vendor/autoload.php';
141144
```
142145

143-
**Step 2**`Run once in browser`
146+
**Step 2**`Call the below methid() and Run once in browser`
144147
- This will auto setup your entire application on a `go!`
145148

146149
| Description |
147150
|-----------------------------------------------------------------------------------------------|
148-
| It's important to install vendor in your project root. We use this to get your root [dir] |
151+
| It's important to install vendor in your project root, As we use this to get your root [dir] |
149152
| By default you don't need to define any path again |
150-
| Files you'll see `.env` `.gitignore` `.htaccess` `.user.ini` `init.php` |
153+
| |
154+
| Files you'll see after you reload browser: |
155+
| `.env` `.gitignore` `.htaccess` `.user.ini` `init.php` |
151156

152157
```
153158
use builder\Database\AutoLoader;
154159
155-
AutoLoader::start([
156-
'path' => 'define root path or ignore'
157-
]);
160+
AutoLoader::start();
158161
```
159162

160163
- or -- `Helpers Function`
161164
```
162-
autoloader_start([
163-
'path' => 'define root path or ignore'
164-
]);
165+
autoloader_start('optional_path_to_root');
165166
```
166167

167168
## Init.php File
@@ -1118,17 +1119,35 @@ schema()->dropColumn('table_name', 'column_name');
11181119
```
11191120
</details>
11201121

1121-
## Get Database Config Data
1122+
## Get Database Config
1123+
```
1124+
$db->getConfig()
1125+
```
1126+
1127+
## Get Database Connection
1128+
```
1129+
$db->dbConnection()
1130+
```
1131+
1132+
- or -- `Helpers Function`
1133+
```
1134+
db_connection();
1135+
```
11221136

1123-
| object | Helpers |
1124-
|-------------------|---------------|
1125-
| $db->env() | env() |
1137+
## Get Database Name
1138+
```
1139+
$db->getDatabaseName()
1140+
```
11261141

1142+
## Get Database PDO
1143+
```
1144+
$db->getPDO()
1145+
```
11271146

1128-
## Get Database Connection
1129-
| object | Helpers |
1130-
|-----------------------|-------------------|
1131-
| $db->dbConnection() | db_connection() |
1147+
## Get Database TablePrefix
1148+
```
1149+
$db->getTablePrefix()
1150+
```
11321151

11331152
## Database Import
11341153
- You can use this class to import .sql into a database programatically
@@ -1153,6 +1172,7 @@ $status = $database->import('path_to/orm.sql');
11531172
import('path_to/orm.sql');
11541173
```
11551174

1175+
11561176
## Update Env Variable
11571177
- You can use this class to import .sql into a database programatically
11581178

src/AutoLoader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public static function start(?string $custom_path = null)
7979
'status' => $loader['status'],
8080
'env_path' => $loader['path'],
8181
'message' => $loader['message'],
82-
'env' => $Env,
8382
], $Env->getServers()));
8483
}
8584

src/Traits/AutoLoaderTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace builder\Database\Traits;
66

7+
use builder\Database\Env;
8+
79

810
trait AutoLoaderTrait{
911

@@ -140,7 +142,7 @@ private static function isDummyNotPresent($paths)
140142
*/
141143
private static function getPathsData($realPath)
142144
{
143-
$env = DOT_ENV_CONNECTION['env'];
145+
$env = new Env(DOT_ENV_CONNECTION['server']);
144146
$serverPath = $env->clean_path( DOT_ENV_CONNECTION['server'] );
145147
$realPath = $env->clean_path( $realPath );
146148

src/Traits/ServerTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace builder\Database\Traits;
66

77
use ReflectionClass;
8-
use builder\Database\Env;
8+
99

1010
trait ServerTrait{
1111

@@ -147,7 +147,6 @@ public static function getServers(?string $mode = null)
147147
*/
148148
define('DOT_ENV_CONNECTION', array_merge($data, [
149149
'env_path' => $data['server'],
150-
'env' => new Env($data['server']),
151150
]));
152151
} else{
153152
// Data

0 commit comments

Comments
 (0)