Skip to content

Commit c4d9765

Browse files
author
Fredrick Peter
committed
Hot Fix for Triggers, Pagination, Schema...
1 parent bc0a37b commit c4d9765

30 files changed

+1522
-615
lines changed

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
.env
2-
.gitignore
3-
/database
4-
/storage
1+
/upload
52
/vendor
63
/.idea
74
/.vscode
5+
/demo
6+
/database
7+
/storage
8+
.env
89
.htaccess
10+
.gitignore
911
.user.ini
1012
php.ini
1113
test.php
1214
init.php
1315
composer.lock
14-
sessions.png
15-
/demo
16+
sessions.png

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ was pretty tough. So i decided to create a much more easier way of communicating
8282
* [Database Migration](#database-migration)
8383
* [Create Table Schema](#create-table-schema)
8484
* [Default String Length](#default-string-length)
85+
* [Update Column Default Value](#update-column-default-value)
8586
* [Run Migration](#run-migration)
8687
* [Drop Table](#drop-table)
8788
* [Drop Column](#drop-column)
@@ -115,7 +116,7 @@ Prior to installing `php-orm-database` get the [Composer](https://getcomposer.or
115116
**Step 1** — update your `composer.json`:
116117
```composer.json
117118
"require": {
118-
"peterson/php-orm-database": "^4.1.7"
119+
"peterson/php-orm-database": "^4.1.8"
119120
}
120121
```
121122

@@ -1204,6 +1205,20 @@ Schema::defaultStringLength(200);
12041205
schema()->defaultStringLength(2000);
12051206
```
12061207

1208+
### Update Column Default Value
1209+
- In some cases you may want to update the default column value
1210+
- Yes! It's very much possible with the help of Schema. Takes three (3) params
1211+
- `$tablename` as string
1212+
- `$column_name` as string
1213+
- `$values` as mixed data `NULL` `NOT NULL\|None` `STRING` `current_timestamp()`
1214+
1215+
```
1216+
use builder\Database\Migrations\Schema;
1217+
1218+
Schema::updateColumnDefaultValue('users_table', 'email_column', 'NOT NULL);
1219+
Schema::updateColumnDefaultValue('users_table', 'gender_column', []);
1220+
```
1221+
12071222
### Run Migration
12081223
- You need to pass in `up` as a param
12091224
- This auto create folders/subfolder with read permission

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"require": {
1919
"php": ">=7.2",
2020
"vlucas/phpdotenv": "^5.3",
21-
"yidas/pagination": "^1.0",
2221
"symfony/var-dumper": "^4.0 || ^5.0 || ^6.0",
2322
"ezyang/htmlpurifier": "^4.16.0"
2423
},
@@ -43,7 +42,7 @@
4342
},
4443
"extra": {
4544
"branch-alias": {
46-
"dev-main": "4.1.7-dev"
45+
"dev-main": "4.1.8-dev"
4746
}
4847
},
4948
"minimum-stability": "stable",

src/Capsule/AppManager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ class AppManager extends Constants{
1111

1212
static private $year;
1313

14-
static function initAppManager()
15-
{
16-
self::$year = date('Y', strtotime('now'));
14+
/**
15+
* initialize
16+
*/
17+
public function __construct() {
18+
self::$year = date('Y', time());
1719
}
1820

1921
/**
@@ -23,8 +25,6 @@ static function initAppManager()
2325
*/
2426
static public function envDummy()
2527
{
26-
self::initAppManager();
27-
2828
return preg_replace("/^[ \t]+|[ \t]+$/m", "", 'APP_NAME="ORM Model"
2929
APP_ENV=local
3030
APP_KEY='. self::generateAppKey() .'

src/Collections/Traits/CollectionTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
use builder\Database\Collections\CollectionMapper;
88

99
/**
10-
* @property-read array $proxies_compact
11-
* @property-read array $proxies
12-
* @property-read mixed $instance
13-
* @property-read mixed $pagination
14-
* @property-read bool $is_paginate
10+
* @property array $proxies_compact
11+
* @property array $proxies
12+
* @property mixed $instance
13+
* @property mixed $pagination
14+
* @property bool $is_paginate
1515
*/
1616
trait CollectionTrait{
1717

src/Collections/Traits/RelatedTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77

88
/**
9-
* @property-read bool $is_paginate
10-
* @property-read mixed $pagination
11-
* @property-read bool $unescapeIsObjectWithoutArray
9+
* @property bool $is_paginate
10+
* @property mixed $pagination
11+
* @property bool $unescapeIsObjectWithoutArray
1212
*/
1313
trait RelatedTrait{
1414

src/Dummy/dummyHtaccess.php

Lines changed: 91 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,114 @@
11
<IfModule mod_rewrite.c>
2+
# Start Engine
3+
RewriteEngine On
24

3-
# page speed
4-
<IfModule pagespeed_module>
5-
ModPagespeed on
6-
ModPagespeedEnableFilters rewrite_css,combine_css
7-
ModPagespeedEnableFilters recompress_images
8-
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
9-
ModPagespeedEnableFilters collapse_whitespace,remove_comments
10-
</IfModule>
11-
12-
#Enable gzip compression for resources
13-
<ifModule mod_gzip.c>
14-
mod_gzip_on Yes
15-
mod_gzip_dechunk Yes
16-
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
17-
mod_gzip_item_include handler ^application/x-httpd-php
18-
mod_gzip_item_include mime ^application/javascript$
19-
mod_gzip_item_include mime ^application/x-javascript$
20-
mod_gzip_item_include mime ^text/.*
21-
mod_gzip_item_exclude mime ^image/.*
22-
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
23-
</ifModule>
24-
25-
# Compress resources
26-
<IfModule mod_deflate.c>
27-
SetOutputFilter DEFLATE
28-
AddOutputFilterByType DEFLATE text/html
29-
AddOutputFilterByType DEFLATE application/xhtml+xml
30-
AddOutputFilterByType DEFLATE text/css
31-
AddOutputFilterByType DEFLATE text/javascript
32-
AddOutputFilterByType DEFLATE text/xml
33-
AddOutputFilterByType DEFLATE text/plain
34-
AddOutputFilterByType DEFLATE image/x-icon
35-
AddOutputFilterByType DEFLATE image/svg+xml
36-
AddOutputFilterByType DEFLATE application/rss+xml
37-
AddOutputFilterByType DEFLATE application/javascript
38-
AddOutputFilterByType DEFLATE application/x-javascript
39-
AddOutputFilterByType DEFLATE application/xml
40-
AddOutputFilterByType DEFLATE application/x-font
41-
AddOutputFilterByType DEFLATE application/x-font-truetype
42-
AddOutputFilterByType DEFLATE application/x-font-ttf
43-
AddOutputFilterByType DEFLATE application/x-font-otf
44-
AddOutputFilterByType DEFLATE application/x-font-opentype
45-
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
46-
AddOutputFilterByType DEFLATE font/ttf
47-
AddOutputFilterByType DEFLATE font/otf
48-
AddOutputFilterByType DEFLATE font/opentype
49-
BrowserMatch ^Mozilla/4 gzip-only-text/html
50-
BrowserMatch ^Mozilla/4\.0[678] no-gzip
51-
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
52-
Header append Vary User-Agent env=!dont-vary
53-
</IfModule>
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]
5412

55-
#access plus 1 month | 1 year | 5 seconds | 2 days
56-
<ifModule mod_expires.c>
57-
ExpiresActive On
58-
ExpiresByType text/html "access plus 600 seconds"
59-
ExpiresByType application/xhtml+xml "access plus 600 seconds"
60-
ExpiresByType image/gif "access 1 year"
61-
ExpiresByType image/png "access 1 year"
62-
ExpiresByType image/jpg "access 1 year"
63-
ExpiresByType image/jpeg "access 1 year"
64-
ExpiresByType image/x-icon "access 1 year"
65-
ExpiresByType image/svg+xml "access plus 1 year"
66-
ExpiresByType audio/ogg "access plus 1 year"
67-
ExpiresByType video/mp4 "access plus 1 year"
68-
ExpiresByType video/ogg "access plus 1 year"
69-
ExpiresByType video/webm "access plus 1 year"
70-
ExpiresByType application/atom+xml "access plus 1 hour"
71-
ExpiresByType application/rss+xml "access plus 1 hour"
72-
ExpiresByType application/pdf "access plus 1 month"
73-
ExpiresByType text/css "access 1 month"
74-
ExpiresByType application/javascript "access 1 month"
75-
ExpiresByType text/x-javascript "access 1 month"
76-
ExpiresByType text/x-component "access plus 1 month"
77-
ExpiresByType application/x-shockwave-flash "access 1 month"
78-
ExpiresByType font/opentype "access plus 1 month"
79-
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
80-
ExpiresByType application/x-font-ttf "access plus 1 month"
81-
ExpiresByType application/font-woff "access plus 1 month"
82-
ExpiresByType application/font-woff2 "access plus 1 month"
83-
ExpiresDefault "access plus 30 days"
84-
</ifModule>
13+
# Define additional rules below
14+
#
8515

86-
# BEGIN Cache-Control Headers
87-
# public | private | must-revalidate
88-
# Header set Cache-Control "private, must-revalidate"
89-
# Header set Cache-Control "max-age=2592000, private"
16+
17+
# Cache control headers
9018
<IfModule mod_headers.c>
91-
Header set Connection keep-alive
9219
<filesMatch ".(js|css|xml|gz|html|php)$">
9320
Header append Vary: Accept-Encoding
9421
</filesMatch>
95-
<filesmatch "\.(ico|flv|gif|swf|eot|woff|otf|ttf|svg)$">
22+
<filesMatch "\.(ico|flv|gif|swf|eot|woff|otf|ttf|svg)$">
23+
Header set Cache-Control "max-age=31536000, public"
24+
</filesMatch>
25+
<filesMatch "\.(jpg|jpeg|png)$">
9626
Header set Cache-Control "max-age=31536000, public"
97-
</filesmatch>
98-
<filesmatch "\.(jpg|jpeg|png)$">
99-
Header set Cache-Control "max-age=31536000, public"
100-
</filesmatch>
101-
<filesmatch "\.(css)$">
102-
Header set Cache-Control "max-age=2592000, private"
103-
</filesmatch>
104-
<filesmatch "\.(js)$">
105-
Header set Cache-Control "max-age=2592000, private"
106-
</filesmatch>
107-
<filesMatch "\.(x?html?|php)$">
27+
</filesMatch>
28+
<filesMatch "\.(css)$">
10829
Header set Cache-Control "max-age=2592000, public"
10930
</filesMatch>
31+
<filesMatch "\.(js)$">
32+
Header set Cache-Control "max-age=2592000, public"
33+
</filesMatch>
34+
<filesMatch "\.(x?html?)$">
35+
Header set Cache-Control "public, must-revalidate"
36+
</filesMatch>
37+
<filesMatch "\.(x?php)$">
38+
Header set Cache-Control "private, must-revalidate"
39+
</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>
11049
</IfModule>
111-
50+
11251
# Mod security
11352
<IfModule mod_security.c>
11453
SecFilterScanPOST Off
11554
</IfModule>
116-
55+
11756
# Mod Speling
11857
<IfModule mod_speling.c>
11958
CheckCaseOnly On
12059
CheckSpelling On
12160
</IfModule>
122-
123-
# Start Engine
124-
RewriteEngine On
61+
</IfModule>
12562

126-
63+
<IfModule mod_expires.c>
64+
# Set expiration for different file types
65+
ExpiresActive On
66+
ExpiresByType text/html "access plus 600 seconds"
67+
ExpiresByType application/xhtml+xml "access plus 600 seconds"
68+
ExpiresByType image/gif "access plus 1 year"
69+
ExpiresByType image/png "access plus 1 year"
70+
ExpiresByType image/jpg "access plus 1 year"
71+
ExpiresByType image/jpeg "access plus 1 year"
72+
ExpiresByType image/x-icon "access plus 1 year"
73+
ExpiresByType image/svg+xml "access plus 1 year"
74+
ExpiresByType audio/ogg "access plus 1 year"
75+
ExpiresByType video/mp4 "access plus 1 year"
76+
ExpiresByType video/ogg "access plus 1 year"
77+
ExpiresByType video/webm "access plus 1 year"
78+
ExpiresByType application/atom+xml "access plus 1 hour"
79+
ExpiresByType application/rss+xml "access plus 1 hour"
80+
ExpiresByType application/pdf "access plus 1 month"
81+
ExpiresByType text/css "access 1 month"
82+
ExpiresByType application/javascript "access 1 month"
83+
ExpiresByType text/x-javascript "access 1 month"
84+
ExpiresByType text/x-component "access plus 1 month"
85+
ExpiresByType application/x-shockwave-flash "access 1 month"
86+
ExpiresByType font/opentype "access plus 1 month"
87+
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
88+
ExpiresByType application/x-font-ttf "access plus 1 month"
89+
ExpiresByType application/font-woff "access plus 1 month"
90+
ExpiresByType application/font-woff2 "access plus 1 month"
91+
ExpiresDefault "access plus 30 days"
92+
</IfModule>
93+
94+
<IfModule mod_gzip.c>
95+
# Enable gzip compression for resources
96+
mod_gzip_on Yes
97+
mod_gzip_dechunk Yes
98+
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
99+
mod_gzip_item_include handler ^application/x-httpd-php
100+
mod_gzip_item_include mime ^application/javascript$
101+
mod_gzip_item_include mime ^application/x-javascript$
102+
mod_gzip_item_include mime ^text/.*
103+
mod_gzip_item_exclude mime ^image/.*
104+
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
105+
</IfModule>
106+
107+
<IfModule pagespeed_module>
108+
# Page Speed
109+
ModPagespeed on
110+
ModPagespeedEnableFilters rewrite_css,combine_css
111+
ModPagespeedEnableFilters recompress_images
112+
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
113+
ModPagespeedEnableFilters collapse_whitespace,remove_comments
127114
</IfModule>

src/Migrations/Blueprint.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,21 @@ public function handle()
9797
return $mysqlHandle;
9898
}
9999

100+
// style css
101+
$style = self::$style;
102+
100103
// Handle query
101104
try{
102105
// check if table already exist
103-
if($this->db->tableExist($this->tableName)){
106+
if($this->db->tableExists($this->tableName)){
104107
$message = "Migration
105-
<span style='background: #ee0707; {$this->style}'>
108+
<span style='background: #ee0707; {$style}'>
106109
Failed
107110
</span> Table exist on `{$traceTable}` <br>\n";
108111
}else{
109112
$this->status_runned = true;
110113
$message = "Migration runned
111-
<span style='background: #027b02; {$this->style}'>
114+
<span style='background: #027b02; {$style}'>
112115
Successfully
113116
</span> on
114117
`{$traceTable}` <br>\n";
@@ -145,13 +148,16 @@ public function __destruct()
145148
*/
146149
private function checkDBConnect()
147150
{
151+
// style css
152+
$style = self::$style;
153+
148154
// if database connection is okay
149155
$dbConnection = $this->db->dbConnection();
150156
if($dbConnection['status'] !== self::ERROR_200){
151157
return [
152158
'status' => self::ERROR_404,
153159
'message' => "Connection Error
154-
<span style='background: #ee0707; {$this->style}'>
160+
<span style='background: #ee0707; {$style}'>
155161
Database Connection Error
156162
</span>
157163
`{$dbConnection['message']}` <br>\n",

0 commit comments

Comments
 (0)