Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Devtools Laravel Package

sikessem/laravel-devtools

Laravel DevTools bundles development, debugging, testing, and automation helpers for Laravel. Install via Composer as a dev dependency. Requires PHP 8.3+ (8.3.29+ recommended) and Composer v2+.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require sikessem/laravel-devtools --dev
    

    Publish the config (if needed):

    php artisan vendor:publish --provider="Sikessem\DevTools\DevToolsServiceProvider" --tag="config"
    
  2. First Use Case Run the devtools:serve command to start a local development server with built-in debugging tools:

    php artisan devtools:serve
    

    Access the dashboard at http://localhost:8000/devtools.

  3. Key Features to Explore

    • Request Inspector: View incoming HTTP requests in real-time.
    • Database Query Logger: Log and analyze SQL queries.
    • Route Debugger: Inspect registered routes and their parameters.
    • Artisan Command Tester: Test Artisan commands interactively.

Implementation Patterns

Common Workflows

  1. Debugging HTTP Requests Use the Request Inspector to log and inspect incoming requests during development:

    // Enable request logging in a route or middleware
    use Sikessem\DevTools\Facades\DevTools;
    
    Route::get('/debug', function () {
        DevTools::logRequest(); // Logs the current request
        return response()->json(['status' => 'logged']);
    });
    
  2. Query Analysis Enable the query logger in config/devtools.php:

    'query_logger' => [
        'enabled' => env('DB_QUERY_LOGGER_ENABLED', true),
    ],
    

    View logged queries in the Database tab of the DevTools dashboard.

  3. Route Debugging Use the Route Debugger to inspect routes dynamically:

    php artisan devtools:routes
    

    Or integrate it into your routes file:

    Route::get('/debug-routes', function () {
        return DevTools::debugRoutes();
    });
    
  4. Artisan Command Testing Test commands interactively without running them in the terminal:

    use Sikessem\DevTools\Facades\DevTools;
    
    Route::get('/test-command', function () {
        return DevTools::testCommand('migrate:fresh --seed');
    });
    
  5. Middleware Integration Add DevTools middleware to log requests globally:

    // In app/Http/Kernel.php
    protected $middleware = [
        \Sikessem\DevTools\Http\Middleware\LogRequests::class,
    ];
    

Integration Tips

  • Laravel Mix/Vite: Use DevTools to inspect asset compilation logs by enabling the asset_logger in the config.
  • Queue Workers: Monitor queue jobs in real-time using the Queue Inspector tab.
  • Event Debugging: Log dispatched events with:
    DevTools::logEvent($event);
    
  • Custom Tabs: Extend the dashboard by creating custom tabs (see Extension Points).

Gotchas and Tips

Pitfalls

  1. Performance Overhead

    • The package adds overhead to request processing. Disable unused features in config/devtools.php for production-like environments:
      'enabled' => env('DEVTOOLS_ENABLED', false),
      
    • Avoid using devtools:serve in production.
  2. Query Logger Conflicts

    • If using other query loggers (e.g., Laravel Debugbar), disable the DevTools query logger to prevent duplicate logs.
  3. Route Caching Issues

    • Clear route cache after adding/removing routes if the Route Debugger doesn’t reflect changes:
      php artisan route:clear
      
  4. Session Storage

    • DevTools stores data in the session. Ensure your session driver is configured correctly (e.g., file, database).
  5. Archived Package Risks

    • The package is archived, meaning no new updates are expected. Use with caution in long-term projects. Consider forking or replacing with alternatives like barryvdh/laravel-debugbar or nunomaduro/collision.

Debugging Tips

  1. Log Clearance Clear DevTools logs manually via:

    php artisan devtools:clear
    

    Or programmatically:

    DevTools::clearLogs();
    
  2. Configuration Quirks

    • The devtools:serve command defaults to port 8000. Change it in config/devtools.php:
      'server' => [
          'port' => 8080,
      ],
      
    • Ensure the devtools middleware is not registered in app/Http/Kernel.php for production.
  3. Custom Data Logging Log custom data to the dashboard:

    DevTools::logCustom('user_action', ['action' => 'login', 'user_id' => 1]);
    

Extension Points

  1. Custom Dashboard Tabs Extend the dashboard by creating a service provider:

    use Sikessem\DevTools\Contracts\DevToolsTab;
    
    class CustomTab implements DevToolsTab {
        public function name() { return 'Custom Tab'; }
        public function view() { return 'devtools::custom.tab'; }
        public function data() { return ['key' => 'value']; }
    }
    

    Register it in config/devtools.php:

    'tabs' => [
        \App\Providers\CustomTab::class,
    ],
    
  2. Event Listeners Listen for DevTools events (e.g., DevToolsRequestLogged):

    use Sikessem\DevTools\Events\RequestLogged;
    
    Event::listen(RequestLogged::class, function ($event) {
        // Custom logic when a request is logged
    });
    
  3. Override Views Publish and override DevTools views:

    php artisan vendor:publish --tag="devtools-views"
    

    Modify files in resources/views/vendor/devtools/.

  4. API Access Access DevTools data via HTTP API (if enabled in config):

    $logs = DevTools::api()->getLogs();
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky