Skip to content

Commit

Permalink
ServerTrait Error Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrick Peter committed Sep 20, 2023
1 parent b873387 commit 093adce
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
58 changes: 39 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ was pretty tough. So i decided to create a much more easier way of communicating
* [Drop Migration](#drop-migration)
* [Drop Table](#drop-table)
* [Drop Column](#drop-column)
* [Get Database Config Data](#get-database-config-data)
* [Get Database Config](#get-database-config)
* [Get Database Connection](#get-database-connection)
* [Get Database Name](#get-database-name)
* [Get Database PDO](#get-database-pdo)
* [Get Database TablePrefix](#get-database-tableprefix)
* [Database Import](#database-import)
* [Update Env Variable](#update-env-variable)
* [Env Servers](#Env-servers)
Expand All @@ -119,7 +122,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
**Step 1** — update your `composer.json`:
```composer.json
"require": {
"peterson/database": "^4.3.5"
"peterson/database": "^4.3.6"
}
```

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

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

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

```
use builder\Database\AutoLoader;
AutoLoader::start([
'path' => 'define root path or ignore'
]);
AutoLoader::start();
```

- or -- `Helpers Function`
```
autoloader_start([
'path' => 'define root path or ignore'
]);
autoloader_start('optional_path_to_root');
```

## Init.php File
Expand Down Expand Up @@ -1118,17 +1119,35 @@ schema()->dropColumn('table_name', 'column_name');
```
</details>

## Get Database Config Data
## Get Database Config
```
$db->getConfig()
```

## Get Database Connection
```
$db->dbConnection()
```

- or -- `Helpers Function`
```
db_connection();
```

| object | Helpers |
|-------------------|---------------|
| $db->env() | env() |
## Get Database Name
```
$db->getDatabaseName()
```

## Get Database PDO
```
$db->getPDO()
```

## Get Database Connection
| object | Helpers |
|-----------------------|-------------------|
| $db->dbConnection() | db_connection() |
## Get Database TablePrefix
```
$db->getTablePrefix()
```

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


## Update Env Variable
- You can use this class to import .sql into a database programatically

Expand Down
1 change: 0 additions & 1 deletion src/AutoLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public static function start(?string $custom_path = null)
'status' => $loader['status'],
'env_path' => $loader['path'],
'message' => $loader['message'],
'env' => $Env,
], $Env->getServers()));
}

Expand Down
4 changes: 3 additions & 1 deletion src/Traits/AutoLoaderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace builder\Database\Traits;

use builder\Database\Env;


trait AutoLoaderTrait{

Expand Down Expand Up @@ -140,7 +142,7 @@ private static function isDummyNotPresent($paths)
*/
private static function getPathsData($realPath)
{
$env = DOT_ENV_CONNECTION['env'];
$env = new Env(DOT_ENV_CONNECTION['server']);
$serverPath = $env->clean_path( DOT_ENV_CONNECTION['server'] );
$realPath = $env->clean_path( $realPath );

Expand Down
3 changes: 1 addition & 2 deletions src/Traits/ServerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace builder\Database\Traits;

use ReflectionClass;
use builder\Database\Env;


trait ServerTrait{

Expand Down Expand Up @@ -147,7 +147,6 @@ public static function getServers(?string $mode = null)
*/
define('DOT_ENV_CONNECTION', array_merge($data, [
'env_path' => $data['server'],
'env' => new Env($data['server']),
]));
} else{
// Data
Expand Down

0 comments on commit 093adce

Please sign in to comment.