https://github.com/ducconit/laravel-module
https://github.com/ducconit/laravel-module
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ducconit/laravel-module
- Owner: ducconit
- License: mit
- Created: 2022-02-27T19:55:43.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-03T19:37:19.000Z (about 3 years ago)
- Last Synced: 2025-02-17T19:17:25.971Z (3 months ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# LARAVEL MODULE
### SETUP
```
composer require dnt/laravel-module
```- require php >= 8.1
### MODULE.JSON
- file in path: `modules/{namemodule}/module.json`
- template:
```json
{
"name": "NameModule",
"key": "key-module",
"providers": [
"namespace service provider"
],
"aliases": {
"alias": "namespace class"
},
"files": [
"file path"
],
"views": [
"./views"
],
"langs": [
"./lang"
],
"enable": true
}
```### EXAMPLE
- Module cart manager
- Struct
```
|-app
|-bootstrap
|-config
...
|-modules
|----CartManager
|-------Facades
|-----------Cart.php
|-------Providers
|-----------CartManagerServiceProvider.php
|-------views
|------------index.blade.php
|-------lang
|------------en
|----------------validation.php
|------------en.json
|-------helpers.php
|-------module.json
...
|-composer.json
|.env
...
```
```json
{
"name": "Cart Manager",
"key": "cart-manager",
"providers": [
"CartManager\\Providers\\CartManagerServiceProvider"
],
"aliases": {
"Cart": "CartManager\\Facades\\Cart"
},
"files": [
"./helpers.php"
],
"views": [
"./views"
],
"langs": [
"./lang"
],
"enable": true
}
```# HELPER
- get module
```php
app(\DNT\Module\Contracts\Management::class)->get('cart-manager');
```
- get all module
```php
app(\DNT\Module\Contracts\Management::class)->all();
```
- enable module
```php
app(\DNT\Module\Contracts\Management::class)->enable('cart-manager');
```
- disable module
```php
app(\DNT\Module\Contracts\Management::class)->disable('cart-manager');
```
- get view
```php
// Controller
...
return view('cart-manager::index');
...
```
- get translation
```php
__('cart-manager::name');
```