Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Clubphp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Clubphp
Commits
335cde0c
Commit
335cde0c
authored
Apr 07, 2026
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 1 files via Son of Anton
parent
56b6d45d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
37 deletions
+17
-37
App.php
app/Core/App.php
+17
-37
No files found.
app/Core/App.php
View file @
335cde0c
...
...
@@ -36,31 +36,18 @@ final class App
return
$this
;
}
// Set timezone
date_default_timezone_set
(
'Africa/Cairo'
);
// Load .env
$this
->
loadEnv
();
// Load config files
$this
->
loadConfig
();
// Initialize error handler
ExceptionHandler
::
register
();
// Initialize database
$this
->
initDatabase
();
// Initialize session
$this
->
initSession
();
// Load DB config overrides
$this
->
loadDbConfigOverrides
();
// Auto-discover and load module bootstraps
$this
->
loadModuleBootstraps
();
// Auto-discover and load module routes
$this
->
router
=
new
Router
();
$this
->
loadModuleRoutes
();
...
...
@@ -151,18 +138,14 @@ final class App
$value
=
json_decode
(
$value
,
true
)
??
$value
;
break
;
}
// Store as dot notation override
$this
->
config
[
'db_overrides'
][
$row
[
'config_key'
]]
=
$value
;
}
}
catch
(
\Throwable
$e
)
{
// DB might not be ready yet
— ignore
// DB might not be ready yet
}
}
/**
* Auto-discover and require all Modules/*/
bootstrap
.
php
files
.
*
This
is
where
modules
register
their
menu
items
,
permissions
,
event
listeners
,
etc
.
*/
// Load all module bootstrap files
private
function
loadModuleBootstraps
()
:
void
{
$modulesDir
=
$this
->
basePath
.
'/app/Modules'
;
...
...
@@ -170,12 +153,13 @@ final class App
return
;
}
$bootstrapFiles
=
glob
(
$modulesDir
.
'/*/bootstrap.php'
);
$pattern
=
$modulesDir
.
DIRECTORY_SEPARATOR
.
'*'
.
DIRECTORY_SEPARATOR
.
'bootstrap.php'
;
$bootstrapFiles
=
glob
(
$pattern
);
if
(
$bootstrapFiles
===
false
)
{
return
;
}
sort
(
$bootstrapFiles
);
// Alphabetical order for deterministic loading
sort
(
$bootstrapFiles
);
foreach
(
$bootstrapFiles
as
$file
)
{
try
{
...
...
@@ -186,9 +170,7 @@ final class App
}
}
/**
* Auto-discover and merge all Modules/*/
Routes
.
php
files
.
*/
// Load all module route files
private
function
loadModuleRoutes
()
:
void
{
$modulesDir
=
$this
->
basePath
.
'/app/Modules'
;
...
...
@@ -196,7 +178,8 @@ final class App
return
;
}
$routeFiles
=
glob
(
$modulesDir
.
'/*/Routes.php'
);
$pattern
=
$modulesDir
.
DIRECTORY_SEPARATOR
.
'*'
.
DIRECTORY_SEPARATOR
.
'Routes.php'
;
$routeFiles
=
glob
(
$pattern
);
if
(
$routeFiles
===
false
)
{
return
;
}
...
...
@@ -210,11 +193,11 @@ final class App
foreach
(
$routes
as
$route
)
{
if
(
is_array
(
$route
)
&&
count
(
$route
)
>=
3
)
{
$this
->
router
->
addRoute
(
$route
[
0
],
// method
$route
[
1
],
// path
$route
[
2
],
// controller@action
$route
[
3
]
??
[],
// middleware
$route
[
4
]
??
null
// permission
$route
[
0
],
$route
[
1
],
$route
[
2
],
$route
[
3
]
??
[],
$route
[
4
]
??
null
);
}
}
...
...
@@ -225,8 +208,6 @@ final class App
}
}
// ── Accessors ──
public
function
db
()
:
Database
{
return
$this
->
db
;
...
...
@@ -248,12 +229,10 @@ final class App
return
$this
->
config
;
}
// Check DB overrides first
if
(
isset
(
$this
->
config
[
'db_overrides'
][
$key
]))
{
return
$this
->
config
[
'db_overrides'
][
$key
];
}
// Dot notation: 'app.name' → $this->config['app']['name']
$parts
=
explode
(
'.'
,
$key
);
$value
=
$this
->
config
;
...
...
@@ -283,7 +262,10 @@ final class App
return
$this
->
basePath
.
'/storage'
;
}
// ── Employee Context ──
public
function
isDebug
()
:
bool
{
return
(
bool
)
$this
->
config
(
'app.debug'
,
false
);
}
public
function
setCurrentEmployee
(
object
$employee
)
:
void
{
...
...
@@ -305,8 +287,6 @@ final class App
return
$this
->
currentBranch
;
}
// ── Simple Service Container ──
public
function
bind
(
string
$key
,
$value
)
:
void
{
$this
->
bindings
[
$key
]
=
$value
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment