Skip to content

Commit 8041098

Browse files
author
Fredrick Peter
committed
namespace name change
1 parent dec101b commit 8041098

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+413
-2716
lines changed

README.md

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ was pretty tough. So i decided to create a much more easier way of communicating
4242
* [Paginate](#paginate)
4343
* [Exist](#exists)
4444
* [Table Exists](#table-exists)
45-
* [Asset](#Asset)
46-
* [Asset config](#asset-config)
47-
* [Asset Cache](#asset-cache)
4845
* [Collections](#collections)
4946
* [Collection Methods](#collection-methods)
5047
* [Collection Usage](#collection-usage)
@@ -113,7 +110,7 @@ was pretty tough. So i decided to create a much more easier way of communicating
113110

114111
## Requirements
115112

116-
- `>= php7.2.5+`
113+
- `>= php 8.0+`
117114

118115
## Installation
119116

@@ -122,7 +119,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
122119
**Step 1** — update your `composer.json`:
123120
```composer.json
124121
"require": {
125-
"peterson/database": "^4.3.7"
122+
"peterson/database": "^4.3.8"
126123
}
127124
```
128125

@@ -133,7 +130,7 @@ composer update
133130

134131
**Or composer require**:
135132
```
136-
composer require peterson/database
133+
composer require tamedevelopers/database
137134
```
138135

139136
## Instantiate
@@ -458,62 +455,6 @@ $db->table('users')
458455
$db->tableExists('users');
459456
```
460457

461-
## Asset
462-
- Takes a param as `string` path to asset file
463-
- Default [dir] is set to `assets`
464-
465-
```
466-
use builder\Database\Asset;
467-
468-
Asset::asset('css/style.css');
469-
470-
- Returns
471-
http://domain.com/assets/css/style.css
472-
```
473-
474-
- or -- `Helpers Function`
475-
```
476-
asset('css/style.css');
477-
```
478-
479-
## Asset Config
480-
- Takes two param as `string`
481-
- `$base_path` path base directory
482-
- `$cache` Tells method to return `cache` of assets.
483-
- You'll see a link representation as `http://domain.com/[path_to_asset_file]?v=111111111`
484-
485-
```
486-
use builder\Database\Asset;
487-
488-
Asset::config('public/storage');
489-
490-
- Returns
491-
http://domain.com/public/storage/[asset_file]
492-
```
493-
494-
- or -- `Helpers Function`
495-
```
496-
asset_config('public');
497-
```
498-
499-
### Asset Cache
500-
- By Default, `$cache` is set to `true`
501-
502-
```
503-
Asset::config('storage', false);
504-
505-
- Returns
506-
http://domain.com/storage/[asset_file]
507-
```
508-
509-
- or -- `Helpers Function`
510-
```
511-
asset_config('storage');
512-
513-
http://domain.com/storage/[asset_file]?v=111111111
514-
```
515-
516-
517458
## Collections
518459
- You can directly use `methods` of `Collections Instance` on any of the below
519460
- All the below `methods` are received by Collection `class`

composer.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "peterson/database",
2+
"name": "tamedevelopers/database",
33
"type": "library",
44
"description": "Lightweight PHP ORM Database Model.",
55
"keywords": ["php orm database", "orm database", "php database", "php orm github"],
@@ -16,27 +16,23 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.2.5",
20-
"psr/log": "^1.0 || ^1.1.4",
21-
"vlucas/phpdotenv": "^5.3",
19+
"php": ">=8.0",
20+
"vlucas/phpdotenv": "^5.4.1",
2221
"filp/whoops": "^2.15",
23-
"symfony/var-dumper": "^5.4.3"
24-
},
25-
"conflict": {
26-
"symfony/var-dumper": ">=6.0.0"
22+
"tamedevelopers/support": "*"
2723
},
2824
"autoload": {
2925
"files": [
3026
"src/helpers.php"
3127
],
3228
"psr-4": {
33-
"builder\\Database\\": "src/"
29+
"Tamedevelopers\\Database\\": "src/"
3430
},
3531
"classmap": ["src/*"]
3632
},
3733
"autoload-dev": {
3834
"psr-4": {
39-
"builder\\Database\\Tests\\": "tests/"
35+
"Tamedevelopers\\Database\\Tests\\": "tests/"
4036
}
4137
},
4238
"minimum-stability": "stable",

src/Asset.php

Lines changed: 0 additions & 104 deletions
This file was deleted.

src/AutoLoader.php

Lines changed: 9 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
declare(strict_types=1);
44

5-
namespace builder\Database;
5+
namespace Tamedevelopers\Database;
66

7-
use builder\Database\Env;
8-
use builder\Database\Traits\AutoLoaderTrait;
9-
use builder\Database\Schema\Pagination\PaginatorAsset;
7+
use Tamedevelopers\Support\Env;
8+
use Tamedevelopers\Database\Traits\AutoLoaderTrait;
9+
use Tamedevelopers\Database\Schema\Pagination\PaginatorAsset;
1010

1111
class AutoLoader{
1212

1313
use AutoLoaderTrait;
1414

1515
protected static $default;
16-
16+
1717
/**
1818
* Star env configuration
1919
*
@@ -44,42 +44,20 @@ public static function start(?string $custom_path = null)
4444
| Load environment file (associated to database)
4545
|--------------------------------------------------------------------------
4646
| This will automatically6 setup our database configuration if found
47+
| or exit with error status code
4748
|
4849
*/
49-
$loader = $Env::loadOrFail();
50-
51-
/*
52-
|--------------------------------------------------------------------------
53-
| Check If There was an error getting the environment file
54-
|--------------------------------------------------------------------------
55-
|
56-
| If there's an error then exit code from running, as this will cause
57-
| Error on using the Database model
58-
|
59-
*/
60-
if($loader['status'] != 200){
61-
/**
62-
* Dump error message
63-
*/
64-
$Env->dump( $loader['message'] );
65-
die(1);
66-
}
50+
$Env::loadOrFail();
6751

6852
/*
6953
|--------------------------------------------------------------------------
7054
| Storing data into a Constant once everything is successful
7155
|--------------------------------------------------------------------------
7256
| We can now use on anywhere on our application
7357
| Mostly to get our defined .env root Path
74-
|
75-
| DOT_ENV_CONNECTION['env_path'] -> return array of data containing .env path
7658
*/
77-
if ( ! defined('DOT_ENV_CONNECTION') ) {
78-
define('DOT_ENV_CONNECTION', array_merge([
79-
'status' => $loader['status'],
80-
'env_path' => $loader['path'],
81-
'message' => $loader['message'],
82-
], $Env->getServers()));
59+
if ( ! defined('TAME_SERVER_CONNECT') ) {
60+
define('TAME_SERVER_CONNECT', $Env->getServers());
8361
}
8462

8563
/*
@@ -138,50 +116,4 @@ public static function configPagination(?array $options = [])
138116
}
139117
}
140118

141-
/**
142-
* Get the value of a configuration option.
143-
*
144-
* @param string $key
145-
* The configuration key in dot notation (e.g., 'database.connections.mysql')
146-
*
147-
* @param mixed $default
148-
* [optional] The default value to return if the configuration option is not found
149-
*
150-
* @return mixed
151-
* The value of the configuration option, or null if it doesn't exist
152-
*/
153-
public static function config(string $key, $default = null)
154-
{
155-
// Convert the key to an array
156-
$parts = explode('.', $key);
157-
158-
// Get the file name
159-
$filePath = base_path("config/{$parts[0]}.php");
160-
161-
// Check if the configuration file exists
162-
if (file_exists($filePath)) {
163-
// Load the configuration array from the file
164-
$config = require($filePath);
165-
}
166-
167-
// Remove the file name from the parts array
168-
unset($parts[0]);
169-
170-
// Compile the configuration value
171-
foreach ($parts as $part) {
172-
if (isset($config[$part])) {
173-
$config = $config[$part];
174-
} else {
175-
$config = null;
176-
}
177-
}
178-
179-
// try merging data if an array
180-
if(is_array($config) && is_array($default)){
181-
return array_merge($config, $default);
182-
}
183-
184-
return $config ?? $default;
185-
}
186-
187119
}

0 commit comments

Comments
 (0)