9
9
10
10
A powerful modular extension framework for Laravel 12+ that enables you to build scalable, maintainable applications with runtime discovery, activation control, and scaffolding utilities.
11
11
12
- ## 🚀 Features
12
+ ## 🚀 Key Features
13
13
14
14
- ** Runtime Discovery** : Automatically discover and load extensions from configured directories
15
15
- ** Activation Management** : Enable/disable extensions with dependency checks and protection mechanisms
16
16
- ** Flexible Storage** : Choose between file-based or database activators for persistence
17
17
- ** Rich API** : Manage extensions through facade, HTTP API, and Artisan commands
18
18
- ** Async Operations** : Queue enable/disable/install operations with status monitoring
19
- - ** Dependency Resolution** : Smart dependency management with conflict detection
20
19
- ** Code Generation** : Scaffold new extensions with customizable stubs
21
20
- ** Event System** : Comprehensive event dispatching for extension lifecycle
22
21
- ** Multi-type Support** : Support for different extension types (Modules, Themes, etc.)
@@ -37,13 +36,13 @@ composer require gigabait93/laravel-extensions
37
36
Publish the configuration file:
38
37
39
38
``` bash
40
- php artisan extensions :publish --tag=extensions-config
39
+ php artisan vendor :publish --tag=extensions-config
41
40
```
42
41
43
42
If using database activator, publish and run migrations:
44
43
45
44
``` bash
46
- php artisan extensions :publish --tag=extensions-migrations
45
+ php artisan vendor :publish --tag=extensions-migrations
47
46
php artisan migrate
48
47
```
49
48
@@ -53,103 +52,25 @@ Discover existing extensions:
53
52
php artisan extensions:discover
54
53
```
55
54
56
- ## 🏗️ Extension Structure
57
-
58
- Extensions are organized in type-based directories:
59
-
60
- ```
61
- extensions/
62
- ├── Modules/
63
- │ ├── Blog/
64
- │ │ ├── extension.json
65
- │ │ ├── composer.json
66
- │ │ ├── helpers.php
67
- │ │ ├── Providers/
68
- │ │ │ └── BlogServiceProvider.php
69
- │ │ ├── Routes/
70
- │ │ │ ├── web.php
71
- │ │ │ └── api.php
72
- │ │ ├── Http/
73
- │ │ │ └── Controllers/
74
- │ │ ├── Models/
75
- │ │ ├── Database/
76
- │ │ │ ├── Migrations/
77
- │ │ │ └── Seeders/
78
- │ │ └── Resources/
79
- │ │ └── views/
80
- │ └── Shop/
81
- ├── Themes/
82
- │ └── Admin/
83
- └── Plugins/
84
- └── Analytics/
85
- ```
86
-
87
- ### Extension Manifest (extension.json)
88
-
89
- ``` json
90
- {
91
- "id" : " blog" ,
92
- "name" : " Blog" ,
93
- "provider" : " Modules\\ Blog\\ Providers\\ BlogServiceProvider" ,
94
- "type" : " Modules" ,
95
- "description" : " Simple blog module" ,
96
- "author" : " John Doe" ,
97
- "version" : " 1.0.0" ,
98
- "compatible_with" : " ^12.0" ,
99
- "requires_extensions" : [" base" ],
100
- "meta" : {
101
- "category" : " content"
102
- }
103
- }
104
- ```
105
-
106
- ## 🎨 Usage
107
-
108
- ### Basic Operations
55
+ ## 🎯 Quick Start
109
56
110
57
``` php
111
58
use Gigabait93\Extensions\Facades\Extensions;
112
59
113
60
// Get all extensions
114
61
$extensions = Extensions::all();
115
62
116
- // Get active extensions
117
- $active = Extensions::enabled();
118
-
119
- // Find specific extension
120
- $blog = Extensions::find('blog');
121
-
122
- // Get extension by ID
123
- $extension = Extensions::get('blog');
124
-
125
63
// Enable extension
126
64
Extensions::enable('blog');
127
65
128
- // Disable extension
66
+ // Disable extension
129
67
Extensions::disable('blog');
130
68
131
- // Install extension dependencies
132
- Extensions::installDependencies('blog');
133
-
134
69
// Install dependencies and enable
135
70
Extensions::installAndEnable('blog');
136
71
```
137
72
138
- ### Async Operations
139
-
140
- ``` php
141
- use Gigabait93\Extensions\Jobs\ExtensionEnableJob;
142
- use Gigabait93\Extensions\Jobs\ExtensionDisableJob;
143
- use Gigabait93\Extensions\Jobs\ExtensionInstallDepsJob;
144
-
145
- // Queue extension operations
146
- Extensions::enableAsync('blog');
147
- Extensions::disableAsync('shop');
148
- Extensions::installDepsAsync('analytics');
149
- Extensions::installAndEnableAsync('blog');
150
- ```
151
-
152
- ### Artisan Commands
73
+ ### Basic Commands
153
74
154
75
``` bash
155
76
# List all extensions
@@ -158,133 +79,22 @@ php artisan extensions:list
158
79
# Enable extension
159
80
php artisan extensions:enable blog
160
81
161
- # Disable extension
162
- php artisan extensions:disable blog
163
-
164
- # Install dependencies
165
- php artisan extensions:install-deps blog
166
-
167
82
# Create new extension
168
83
php artisan extensions:make Blog --type=module
169
-
170
- # Migrate extensions
171
- php artisan extensions:migrate
172
-
173
- # Publish extension assets
174
- php artisan extensions:publish blog
175
-
176
- # Reload extensions cache
177
- php artisan extensions:reload
178
84
```
179
85
180
- ## 🎭 Events
181
-
182
- The package dispatches various events during extension lifecycle:
183
-
184
- ``` php
185
- use Gigabait93\Extensions\Events\{
186
- ExtensionEnabledEvent,
187
- ExtensionDisabledEvent,
188
- ExtensionDiscoveredEvent,
189
- ExtensionDeletedEvent,
190
- ExtensionDepsInstalledEvent
191
- };
192
-
193
- // Listen to extension events
194
- Event::listen(ExtensionEnabledEvent::class, function ($event) {
195
- logger()->info("Extension {$event->extension->name} was enabled");
196
- });
197
-
198
- Event::listen(ExtensionDisabledEvent::class, function ($event) {
199
- logger()->info("Extension {$event->extension->name} was disabled");
200
- });
201
- ```
202
-
203
- ## ⚙️ Configuration
204
-
205
- Configure the package in ` config/extensions.php ` :
86
+ ## 📚 Documentation
206
87
207
- ``` php
208
- return [
209
- // Extensions that cannot be disabled
210
- 'protected' => [
211
- 'Modules' => 'ExtensionsDebugger',
212
- ],
213
-
214
- // Loading order for active extensions
215
- 'load_order' => [
216
- 'Modules' => 'ExtensionsDebugger',
217
- ],
218
-
219
- // Mutually exclusive extension types
220
- 'switch_types' => [
221
- 'Themes',
222
- ],
223
-
224
- // Extension directories by type
225
- 'paths' => [
226
- 'Modules' => base_path('extensions/Modules'),
227
- 'Themes' => base_path('extensions/Themes'),
228
- ],
229
-
230
- // Stub configuration for scaffolding
231
- 'stubs' => [
232
- 'path' => null, // Use package stubs
233
- 'default' => [
234
- 'config', 'console', 'database', 'events',
235
- 'exceptions', 'facades', 'helpers', 'http',
236
- 'jobs', 'lang', 'listeners', 'models',
237
- 'notifications', 'policies', 'resources',
238
- 'routes', 'rules', 'services',
239
- ],
240
- ],
241
-
242
- // Activator class for managing states
243
- 'activator' => \Gigabait93\Extensions\Activators\FileActivator::class,
244
-
245
- // JSON file path for FileActivator
246
- 'json_file' => base_path('storage/extensions.json'),
247
- ];
248
- ```
88
+ For detailed documentation, visit [ https://gigabait93.github.io/laravel-extensions/ ] ( https://gigabait93.github.io/laravel-extensions/ ) .
249
89
250
90
## 🧪 Testing
251
91
252
- Run the test suite:
253
-
254
92
``` bash
255
93
composer test
256
- ```
257
-
258
- Run code style checks:
259
-
260
- ``` bash
261
- composer cs-check
262
- ```
263
-
264
- Fix code style issues:
265
-
266
- ``` bash
267
94
composer cs-fix
268
- ```
269
-
270
- Run static analysis:
271
-
272
- ``` bash
273
95
composer phpstan
274
96
```
275
97
276
- ## 📚 Documentation
277
-
278
- For detailed documentation, visit [ https://gigabait93.github.io/laravel-extensions/ ] ( https://gigabait93.github.io/laravel-extensions/ ) .
279
-
280
- The documentation covers:
281
- - Installation and configuration
282
- - Extension development
283
- - Manifest format reference
284
- - Event system
285
- - API reference
286
- - Best practices
287
-
288
98
## 🤝 Contributing
289
99
290
100
Contributions are welcome! Please feel free to submit a Pull Request.
0 commit comments