Warning
This package is in early development and should be considered experimental. Expect frequent changes, incomplete features, and breaking updates.
Contributions and feedback are welcome, but use in production is not recommended until a stable version is tagged.
Track progress and open issues here: GitHub Issues
Track and identify dead code in your Laravel applications.
Laravel Tombstones helps you identify potentially dead code by placing markers (tombstones) in your codebase and tracking whether they're executed. This makes it safer to remove unused code paths and keep your application lean.
Install via Composer:
composer require jorbascrumps/laravel-tombstonesAdd tombstone markers to code you suspect might be dead:
class UserController extends Controller
{
public function legacyMethod()
{
tombstone('legacy-user-method');
// Your potentially dead code here
return view('legacy.user');
}
}Provide additional context when placing tombstones:
tombstone('checkout-flow-v1', [
'user_id' => auth()->id(),
]);Run the report command to see which tombstones are alive or dead:
php artisan tombstone:reportTip
Start by adding tombstones to code paths you're unsure about, then monitor them over several weeks of normal application usage.
You can define configuration variables in your .env file:
| Variable | Default | Description |
|---|---|---|
TOMBSTONE_DRIVER |
local |
Storage driver for tombstone logs |
TOMBSTONE_PATH |
storage_path('tombstones') |
Path where tombstone logs are stored |
TOMBSTONE_FILENAME |
tombstones.jsonl |
Log filename |
TOMBSTONE_TRACE_DEPTH |
1 |
Stack trace depth for context |
First publish the configuration file:
php artisan vendor:publish --provider="Jorbascrumps\LaravelTombstones\ServiceProvider"Implement the provided reader/ writer contracts:
use Jorbascrumps\LaravelTombstones\Contracts\TombstoneWriterContract;
class DatabaseWriter implements TombstoneWriterContract
{
public function write(Tombstone $tombstone): void
{
// Your custom storage logic
}
}Register your custom implementation in:
'writer' => YourCompany\YourApplication\DatabaseWriter::class,