Skip to content

Commit e89bf17

Browse files
committed
feat(app): Added CI_App application driver spine
Introduce a bare-bones `CI_App` driver library as the application-level entry point, parallel to `CI_Hub` but scoped to domain logic. Includes an empty drivers directory to establish the extension surface. `CI_App` is shipped inactive by default and intended to be autoloaded only when an application requires app-side hooks or drivers.
1 parent 261bf68 commit e89bf17

4 files changed

Lines changed: 99 additions & 3 deletions

File tree

application/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| Used to track app status and possibly check for updates.
99
|
1010
*/
11-
const APP_VERSION = '0.1.1';
11+
const APP_VERSION = '0.1.2';
1212
const APP_REPO = 'ianhubnet/csk-app-default';
1313

1414
/*

application/config/constants.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
defined('BASEPATH') || exit('A moment of silence for your attempt.');
4-
53
/**
64
* Application Constants
75
*

application/libraries/App/App.php

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
/**
4+
* CI_App
5+
*
6+
* Application-level driver library.
7+
*
8+
* Acts as the main entry point for application-specific logic and domain
9+
* drivers, fully isolated from the framework/core layer (CI_Hub).
10+
*
11+
* This class is intentionally lightweight by default and may remain unused
12+
* unless explicitly autoloaded by the application..
13+
*
14+
* @package App\Libraries
15+
* @subpackage Drivers
16+
* @author Kader Bouyakoub <bkader[at]mail[dot]com>
17+
* @copyright Copyright (c) 2025, Kader Bouyakoub
18+
*/
19+
20+
final class CI_App extends CI_Driver_Library
21+
{
22+
/**
23+
* Reference to the CodeIgniter super-object.
24+
*
25+
* Used to access loaders, hooks, config, and other shared services.
26+
*
27+
* @var CI_Controller
28+
*/
29+
protected $ci;
30+
31+
/**
32+
* List of allowed application drivers.
33+
*
34+
* This list is filterable to allow applications or modules to register
35+
* their own drivers without modifying this class.
36+
*
37+
* @var array<string>
38+
*/
39+
protected $valid_drivers;
40+
41+
// --------------------------------------------------------------------
42+
43+
/**
44+
* Class constructor.
45+
*
46+
* Initializes the application driver library and prepares the list
47+
* of valid drivers. Logic here is not executed unless the library is
48+
* explicitly (auto)loaded.
49+
*
50+
* @return void
51+
*/
52+
public function __construct()
53+
{
54+
// Cache the CI super-object for convenience and performance.
55+
$this->ci ??= CI_Controller::get_instance();
56+
57+
/**
58+
* Filter the list of application drivers.
59+
*
60+
* Applications are expected to register their drivers through
61+
* the `app_drivers` filter when needed. However, default drivers
62+
* can be added here and the filter is left to modules and plugins.
63+
*/
64+
$this->valid_drivers = $this->ci->hooks->filter(
65+
'app_drivers',
66+
[], // Add default drivers here.
67+
$this->ci,
68+
$this
69+
);
70+
71+
// Skip runtime setup during installation.
72+
if (CI_INSTALL) {
73+
return;
74+
}
75+
76+
// Allow the application to hook into runtime execution.
77+
$this->setup_runtime();
78+
}
79+
80+
// --------------------------------------------------------------------
81+
82+
/**
83+
* Performs optional runtime setup.
84+
*
85+
* Intended for registering hooks, menus, listeners, or other
86+
* application-specific behavior.
87+
*
88+
* This method is intentionally empty in the default distribution
89+
* and should only be implemented when the application requires it.
90+
*
91+
* @return void
92+
*/
93+
private function setup_runtime()
94+
{
95+
// Intentionally left blank.
96+
}
97+
98+
}
File renamed without changes.

0 commit comments

Comments
 (0)