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

Boris Laravel Package

d11wtq/boris

Interactive REPL for PHP powered by Boris. Drop into a console and inspect variables, evaluate code, explore objects, and debug applications quickly from the command line with an easy, lightweight shell.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require d11wtq/boris --dev
    

    Add to composer.json under require-dev to avoid production bloat.

  2. First Run:

    vendor/bin/boris
    
    • No config needed. Boris auto-detects your project’s vendor/autoload.php and loads it.
    • For Laravel projects, run from your project root to leverage the framework’s autoloader.
  3. First Use Case:

    • Inspect Laravel Facades:
      // Inside Boris REPL:
      $user = App\Models\User::first();
      dd($user->toArray());
      
    • Test Helper Functions:
      str()->slug('Hello World'); // Laravel's Str helper
      
    • Debug Middleware/Service Providers:
      $request = new \Illuminate\Http\Request();
      $response = app()->handle($request);
      

Implementation Patterns

Workflows

  1. Rapid Prototyping:

    • Test snippets of code without saving files. Example:
      $data = ['name' => 'John', 'email' => 'john@example.com'];
      $user = \App\Models\User::create($data);
      $user->refresh(); // Verify DB state
      
  2. Debugging Live Requests:

    • Simulate HTTP requests in real app context:
      $response = \Illuminate\Support\Facades\Http::get('https://api.example.com/users');
      $response->json();
      
  3. Exploring Framework Internals:

    • Inspect Laravel’s service container:
      app()->bindings(); // List all bound services
      app()->make(\Illuminate\Contracts\Routing\UrlGenerator::class)->to('/');
      
  4. Testing Artisan Commands:

    • Run commands interactively:
      $command = new \App\Console\Commands\GenerateReport();
      $command->handle();
      

Integration Tips

  • Bootstrap Laravel: Run Boris from your project root to auto-load Laravel’s bootstrap/app.php:

    vendor/bin/boris --bootstrap=bootstrap/app.php
    
    • Access the Laravel container directly:
      $mailer = app(\Illuminate\Mail\Mailer::class);
      
  • Custom Aliases: Add shortcuts to ~/.borisrc (if supported) or use PHP’s alias feature:

    alias('u', 'App\Models\User::first()');
    
  • Persistent Sessions: Use --persistent flag (if available) to retain variables between sessions:

    vendor/bin/boris --persistent
    

Gotchas and Tips

Pitfalls

  1. Outdated Package:

    • Last release was in 2015. Test thoroughly in your Laravel version (may need polyfills for newer PHP/Laravel).
    • Workaround: Fork and update dependencies (e.g., psr/log, symfony/console) if compatibility issues arise.
  2. No Laravel-Specific Features:

    • Unlike tightenco/ziggy or laravel/ide-helper, Boris doesn’t natively integrate with Laravel’s helpers (e.g., route(), back(), asset()).
    • Tip: Manually load Laravel’s helpers.php:
      require app_path('Helpers.php');
      
  3. Autoloader Conflicts:

    • If your project uses custom PSR-4 namespaces, ensure vendor/autoload.php is loaded first.
    • Debug: Run composer dump-autoload if classes aren’t found.
  4. Stateful Debugging:

    • Modifying DB records in REPL may cause inconsistencies. Use transactions:
      \DB::transaction(function () {
          $user = App\Models\User::find(1);
          $user->update(['name' => 'Updated']);
      });
      

Debugging Tips

  • Inspect Globals:
    get_defined_vars(); // List all variables in scope
    
  • Enable Error Reporting:
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    
  • Clear Cache: If classes aren’t autoloading:
    composer dump-autoload
    php artisan optimize:clear
    

Extension Points

  1. Custom Prompt: Override the prompt in ~/.borisrc (if supported) or monkeypatch:

    \Boris\Boris::getPromptFunction = function() { return 'laravel> '; };
    
  2. Add Commands: Extend Boris’s command system (if API allows) or use PHP’s register_shutdown_function to auto-load custom snippets.

  3. Logging: Redirect output to a file for debugging:

vendor/bin/boris --log=boris.log


4. **Integration with Laravel Debugbar**:
 Load Debugbar manually:
 ```php
 $debugbar = new \Barryvdh\Debugbar\Debugbar();
 $debugbar->addMessage('REPL Session');

```markdown
### Laravel-Specific Quirks
1. **Service Provider Bootstrapping**:
   - If you need providers to load (e.g., `Hash`, `Cache`), manually boot them:
     ```php
     $app = require_once __DIR__.'/bootstrap/app.php';
     $app->boot();
     ```

2. **Environment Variables**:
   - Load `.env` explicitly:
     ```php
     $dotenv = new \Dotenv\Dotenv(__DIR__);
     $dotenv->load();
     ```

3. **Queue Workers**:
   - Test queue jobs interactively:
     ```php
     $job = new \App\Jobs\SendEmail();
     $job->handle();
     ```

4. **Event Listeners**:
   - Dispatch and listen to events:
     ```php
     event(new \App\Events\UserRegistered());
     ```
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.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver