Skip to content

Instantly share code, notes, and snippets.

@alies-dev
Last active February 26, 2023 21:33
Show Gist options
  • Save alies-dev/527a7f84c89027bd08ec4b4b45c56847 to your computer and use it in GitHub Desktop.
Save alies-dev/527a7f84c89027bd08ec4b4b45c56847 to your computer and use it in GitHub Desktop.
# A basic deptrac config for Laravel application to isolate HTTP context from the rest of the app
# see https://qossmic.github.io/deptrac/
# see https://alies.dev/articles/
deptrac:
paths:
- ./app
layers:
- name: Model
collectors:
- type: extends
extends: '\Illuminate\Database\Eloquent\Model'
- name: Job
collectors:
- type: directory
value: Jobs/.*
- name: Service
collectors:
- type: directory
value: Services/.*
- name: Event
collectors:
- type: directory
regex: Events/.*
- name: Listener
collectors:
- type: directory
regex: Listeners/.*
- name: Observer
collectors:
- type: directory
regex: Observers/.*
- name: Controller
collectors:
- type: class
value: .*Controller.*
- name: FormRequest
collectors:
- type: extends
extends: '\Illuminate\Foundation\Http\FormRequest'
- name: HttpMiddleware
collectors:
- type: className
regex: .*App.*\\Http\\Middleware\\.*
- name: ConsoleCommand
collectors:
- type: extends
extends: '\Illuminate\Console\Command'
- name: RuntimeContext
collectors:
- type: className
regex: 'Illuminate\\Support\\Facades\\Auth'
- type: className
regex: 'Illuminate\\Support\\Facades\\Session'
- type: className
regex: 'Illuminate\\Support\\Facades\\Cookie'
- type: className
regex: 'Illuminate\\Support\\Facades\\Request'
- type: className
regex: 'Illuminate\\Support\\Facades\\Response'
- type: functionName
value: auth
- type: functionName
value: session
- type: functionName
value: cookie
- type: functionName
value: request
- type: functionName
value: response
- type: functionName
value: redirect
- type: functionName
value: old
- type: functionName
value: view
- name: ForbiddenFunctionality
collectors:
- type: functionName
value: dd
- type: functionName
value: dump
- type: functionName
value: var_dump
ruleset:
Model:
- Job
- Event
Job:
- Model
- Service
- Event
Service:
- Model
- Job
- Event
Event:
- Model
Listener:
- Event
- Model
- Job
- Service
Observer:
- Event
- Model
- Service
- Job
Controller:
- RuntimeContext
- FormRequest
- HttpMiddleware
- Service
- Model
- Event
- Job
FormRequest:
- Model
- Service
- RuntimeContext
HttpMiddleware:
- RuntimeContext
- Model
- Service
ConsoleCommand:
- Service
- Model
- Event
- Job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment