Installation
composer require clickable/dev-tools
Add the service provider to config/app.php under providers:
Clickable\DevTools\DevToolsServiceProvider::class,
Publish Config (Optional)
php artisan vendor:publish --provider="Clickable\DevTools\DevToolsServiceProvider" --tag="config"
This generates config/dev-tools.php with default settings.
First Use Case: Debugging Routes
Run the dev-tools:routes command to list all registered routes with their middleware, controllers, and actions:
php artisan dev-tools:routes
Output includes:
First Use Case: Database Inspection
Use the dev-tools:tables command to inspect database tables, columns, and indexes:
php artisan dev-tools:tables
Filter by table name:
php artisan dev-tools:tables --table=users
List All Routes with Metadata
php artisan dev-tools:routes --json
Outputs structured JSON for programmatic use (e.g., API documentation generation).
Filter Routes by Name or URI
php artisan dev-tools:routes --name="admin.dashboard"
or
php artisan dev-tools:routes --uri="api/v1/users"
Integrate with Route Caching
Use the --cache flag to generate a cached routes file for performance:
php artisan dev-tools:routes --cache
Cache is stored at storage/framework/cache/dev-tools/routes.php.
Compare Schemas Across Environments
Use the --diff flag to compare local and production schemas (requires DB_DATABASE config):
php artisan dev-tools:tables --diff
Generate Migration Snippets Extract schema as a migration file:
php artisan dev-tools:tables --table=posts --migration > database/migrations/2023_11_01_create_posts_table.php
Dump All Config Values
php artisan dev-tools:config
Outputs a tree of all Laravel config values (useful for debugging environment-specific settings).
Search Config by Key
php artisan dev-tools:config --key="app.timezone"
List All Events and Listeners
php artisan dev-tools:events
Includes:
Trace Event Dispatching
Enable event tracing in config/dev-tools.php:
'events' => [
'trace' => true,
],
Then run:
php artisan dev-tools:events --trace
Logs event dispatching to storage/logs/dev-tools-events.log.
Browse Bound Services
php artisan dev-tools:services
Outputs:
Resolve a Specific Service
php artisan dev-tools:services --id="App\Services\UserService"
List All Middleware
php artisan dev-tools:middleware
Includes:
Test Middleware Isolation
Use the --test flag to simulate middleware execution without affecting the request:
php artisan dev-tools:middleware --test --middleware="auth"
Add to phpunit.xml for pre-test debugging:
<env name="DEV_TOOLS_AUTOMATE" value="true"/>
Then run:
php artisan dev-tools:routes --json > routes.json
Create a custom command to combine multiple dev-tools features:
use Clickable\DevTools\Commands\RoutesCommand;
use Clickable\DevTools\Commands\TablesCommand;
class DebugCommand extends Command {
protected $signature = 'debug:full {--routes?} {--tables?}';
protected $description = 'Run multiple dev-tools checks';
public function handle() {
if ($this->option('routes')) {
(new RoutesCommand())->handle();
}
if ($this->option('tables')) {
(new TablesCommand())->handle();
}
}
}
Export dev-tools output as JSON and integrate with IDE plugins (e.g., PHPStorm) for:
Override the default output by extending the base command:
use Clickable\DevTools\Commands\BaseCommand;
class CustomRoutesCommand extends BaseCommand {
protected function getOutputFormat() {
return 'custom'; // Triggers custom output in config
}
}
Performance Overhead
dev-tools:routes or dev-tools:services can be slow on large applications.--cache flag or run during development only.Database Connection Issues
dev-tools:tables requires a valid database connection..env has correct DB_* settings or use --env=production to test against production.Middleware Testing Quirks
--test flag for middleware may not work with global middleware (e.g., App\Http\Middleware\TrustProxies).config/dev-tools.php:
'middleware' => [
'exclude_globals' => true,
],
Event Tracing Overhead
trace: true for events can significantly slow down requests.Config Key Conflicts
app.debug) may conflict with dev-tools internal keys.'dev_tools' => [
'custom_key' => 'value',
],
Enable Verbose Output
Add -v or -vv to commands for debug-level logging:
php artisan dev-tools:routes -vv
Check Logs
Dev-tools logs to storage/logs/dev-tools.log. Enable with:
'logging' => [
'enabled' => true,
],
Validate JSON Output
Use --json to ensure API-compatible output:
php artisan dev-tools:config --json | jq
Reset Cache Clear dev-tools cache if output seems stale:
php artisan cache:clear
php artisan dev-tools:routes --cache
Custom Commands
Extend Clickable\DevTools\Commands\BaseCommand to add new functionality:
namespace App\Console\Commands;
use Clickable\DevTools\Commands\BaseCommand;
class MyCustomCommand extends BaseCommand {
protected $signature = 'dev-tools:my-command';
protected $description = 'My custom dev-tools command';
public function handle() {
$this->info('Extended dev-tools!');
}
}
Modify Output Formatters
Override the formatter in config/dev-tools.php:
'formatters' => [
'routes' => App\Formatters\CustomRoutesFormatter::class,
],
Add New Inspection Targets
Implement the Clickable\DevTools\Contracts\Inspectable interface:
use Clickable\DevTools\Contracts\Inspectable;
class MyInspectable implements Inspectable {
public function inspect() {
return ['key' => 'value'];
}
}
Register in DevToolsServiceProvider:
$this->app->bind('dev-tools.inspectable.my_target', MyInspectable::class);
Hook into Dev-Tools Events
Listen for dev-tools events (e.g., dev-tools.inspecting):
use Clickable\DevTools\Events\Inspecting;
Event::listen
How can I help you explore Laravel packages today?