Skip to content

Commit 31815bd

Browse files
Merge pull request #117 from CodeWithDennis/chore/setup-script-and-boost-refresh
chore: add composer setup script and refresh dependencies
2 parents 9d0fb01 + 04fbb92 commit 31815bd

42 files changed

Lines changed: 1454 additions & 1023 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
name: debug-using-debugbar
3+
description: >
4+
Use this skill to optimize requests or debug Laravel application issues — slow pages, N+1 queries, exceptions,
5+
failed requests, or unexpected behavior — by inspecting data captured by Laravel Debugbar via
6+
Artisan CLI commands. Use when the user asks to investigate a bug, diagnose a slow request,
7+
find duplicate queries, check what happened on a previous request, or optimize database
8+
performance, even if they don't explicitly mention "debugbar" or "profiling."
9+
compatibility: Requires Laravel with fruitcake/laravel-debugbar installed and debug mode enabled.
10+
---
11+
12+
## Debugging and optimizing workflow
13+
14+
1. Find the relevant request:
15+
```bash
16+
php artisan debugbar:find --issues --max=50
17+
```
18+
2. Inspect the request summary to identify which collectors have data:
19+
```bash
20+
php artisan debugbar:get {id}
21+
```
22+
3. Drill into the relevant collector based on the issue type:
23+
```bash
24+
php artisan debugbar:get {id} --collector=exceptions
25+
```
26+
4. For query issues, use dedicated query analysis:
27+
```bash
28+
php artisan debugbar:queries {id}
29+
```
30+
5. Trace the problem to source code using backtraces, then fix and re-test.
31+
32+
## Finding requests
33+
34+
```bash
35+
36+
# List recent requests (shows summary with status, duration, memory, query count)
37+
38+
php artisan debugbar:find
39+
40+
# Filter by URI pattern (fnmatch) and/or HTTP method
41+
42+
php artisan debugbar:find --uri="/api/*" --method=POST
43+
44+
# Only show requests with issues (exceptions, slow queries, duplicates, errors)
45+
46+
php artisan debugbar:find --issues --max=50
47+
48+
# Customize issue thresholds (defaults: --min-queries=50, --min-duration=1000, --min-duplicates=2)
49+
50+
php artisan debugbar:find --issues --min-queries=10 --min-duration=500
51+
52+
# Threshold options also work standalone, filtering on just that criteria
53+
54+
php artisan debugbar:find --min-queries=20
55+
```
56+
57+
`--issues` flags: exceptions, non-2xx status, high query count, slow queries, duplicate query groups, slow request duration, and failed queries. Issue filtering applies on top of the fetched result set — increase `--max` to scan further back.
58+
59+
## Inspecting a request
60+
61+
```bash
62+
63+
# Summary of all collectors (available collectors depend on config)
64+
65+
php artisan debugbar:get latest
66+
php artisan debugbar:get {id}
67+
68+
# Full data for a specific collector
69+
70+
php artisan debugbar:get {id} --collector=exceptions
71+
```
72+
73+
Pick the collector by issue type:
74+
- **Error/500**`exceptions` · **Slow page**`queries`, `time` · **Auth**`auth`, `gate` · **Cache**`cache`
75+
76+
## Analyzing queries
77+
78+
```bash
79+
80+
# Overview with duplicate detection and slow query flags
81+
82+
php artisan debugbar:queries {id}
83+
84+
# Backtrace and params for a specific statement
85+
86+
php artisan debugbar:queries {id} --statement=N
87+
88+
# EXPLAIN plan or re-execute a SELECT
89+
90+
php artisan debugbar:queries {id} --statement=N --explain
91+
php artisan debugbar:queries {id} --statement=N --result
92+
```
93+
94+
Duplicate queries are a strong N+1 signal. Use `--statement=N` to get the backtrace and find the origin.
95+
96+
## Gotchas
97+
98+
- Always start with `debugbar:find --issues` rather than `debugbar:find` — the issue flags surface the most actionable requests immediately.
99+
- The `{id}` is the request ID from the `debugbar:find` output, or use `latest` to inspect the most recent request.
100+
- Collector availability depends on the app's debugbar config — the summary from `debugbar:get` shows which collectors have data.
101+
- `--explain` and `--result` only work on SELECT queries. They re-execute against the current database, so results may differ from the original request.
102+
- `debugbar:clear` removes all stored data — use it to reset between debugging sessions, not mid-investigation.

.cursor/skills/laravel-best-practices/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@ Always use a sub-agent to read rule files and explore this skill's content.
187187

188188
1. Identify the file type and select relevant sections (e.g., migration → §16, controller → §1, §3, §5, §6, §10)
189189
2. Check sibling files for existing patterns — follow those first per Consistency First
190-
3. Verify API syntax with `search-docs` for the installed Laravel version
190+
3. Verify API syntax with `search-docs` for the installed Laravel version

.cursor/skills/laravel-best-practices/rules/advanced-queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ public function scopeOrderByLastLogin($query): void
103103
->take(1)
104104
);
105105
}
106-
```
106+
```

.cursor/skills/laravel-best-practices/rules/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,4 @@ class Customer extends Model
199199
return $this->belongsToMany(Role::class);
200200
}
201201
}
202-
```
202+
```

.cursor/skills/laravel-best-practices/rules/blade-views.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ return view('dashboard', compact('users'))
3333

3434
## Use `@aware` for Deeply Nested Component Props
3535

36-
Avoids re-passing parent props through every level of nested components.
36+
Avoids re-passing parent props through every level of nested components.

.cursor/skills/laravel-best-practices/rules/caching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ If Redis goes down, the app falls back to a secondary store automatically.
6767

6868
```php
6969
'failover' => ['driver' => 'failover', 'stores' => ['redis', 'database']],
70-
```
70+
```

.cursor/skills/laravel-best-practices/rules/collections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ More declarative than overriding `newCollection()`.
4141
```php
4242
#[CollectedBy(UserCollection::class)]
4343
class User extends Model {}
44-
```
44+
```

.cursor/skills/laravel-best-practices/rules/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ If the application already uses language files for localization, use `__()` for
7070
```php
7171
// Only when lang files already exist in the project
7272
return back()->with('message', __('app.article_added'));
73-
```
73+
```

.cursor/skills/laravel-best-practices/rules/db-performance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,4 @@ return view('users.index', compact('users'));
189189
@foreach ($users as $user)
190190
{{ $user->profile->name }}
191191
@endforeach
192-
```
192+
```

.cursor/skills/laravel-best-practices/rules/eloquent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@ Order::where('status', 'pending')->get();
145145

146146
Prefer Eloquent queries and relationships over `DB::table()` whenever possible — they already reference the model's table. When `DB::table()` or raw joins are unavoidable, always use `(new Model)->getTable()` to keep the reference traceable.
147147

148-
**Exception — migrations:** In migrations, hardcoded table names via `DB::table('settings')` are acceptable and preferred. Models change over time but migrations are frozen snapshots — referencing a model that is later renamed or deleted would break the migration.
148+
**Exception — migrations:** In migrations, hardcoded table names via `DB::table('settings')` are acceptable and preferred. Models change over time but migrations are frozen snapshots — referencing a model that is later renamed or deleted would break the migration.

0 commit comments

Comments
 (0)