elitedevsquad / sidecar-laravel
Requires
- php: ^8.2
- laravel/framework: ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- laradumps/laradumps: ^5.0
- larastan/larastan: ^3.0
- laravel/pint: ^1.24
- orchestra/testbench: ^9.4|^10.4|^11.0
- pestphp/pest: ^4.0|^3.8|^4.0
- pestphp/pest-plugin-laravel: ^4.0|^3.2
- 3.x-dev
- v3.0.2
- v3.0.1
- v3.0.0
- 2.x-dev
- v2.1.0
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- 1.x-dev
- v1.3.0
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-fix-badge-verification
- dev-build-assets
- dev-fix/badge-safari-detection
- dev-badge-fallback
- dev-copilot/sub-pr-23
- dev-main
This package is auto-updated.
Last update: 2026-06-02 13:50:57 UTC
README
A Laravel library that lets developers and QA test Laravel apps directly from the browser — run Tinker code, artisan commands, manipulate the fake clock, and impersonate users.
Requirements: PHP ^8.2, Laravel ^11
Install
Run from inside your Laravel project root:
bash <(curl -fsSL https://raw.githubusercontent.com/elitedevsquad/sidecar-laravel/3.x/install.sh)
The script handles everything automatically:
composer require elitedevsquad/sidecar-laravel --dev- Publishes
config/devsquad-sidecar.php - Writes all
.envvariables (auto-detects APP_URL, mail server, git remote) - Mirrors keys into
.env.example - Injects the CSRF meta tag into any blade layout that has
<html>,<body>and<meta>
After running, complete the User Mapping step below.
Manual Setup
If you prefer not to use the install script:
composer require elitedevsquad/sidecar-laravel --dev
php artisan vendor:publish --tag="devsquad-sidecar"
Then add the env variables below, configure user mapping, and ensure the CSRF meta tag is in your main layout:
<meta name="csrf-token" content="{{ csrf_token() }}">
User Mapping
In AppServiceProvider.php, configure Sidecar inside a class_exists() guard so the app does not break when the package is absent (e.g. production with --no-dev):
public function boot(): void { if (class_exists(\EliteDevSquad\SidecarLaravel\Sidecar::class)) { \EliteDevSquad\SidecarLaravel\Sidecar::$userMap = [ 'id' => 'id', 'name' => 'first_name', 'role' => 'role.name', 'email' => 'email', ]; \EliteDevSquad\SidecarLaravel\Sidecar::$userBuilder = \App\Models\User::with('role'); } }
Environment Variables
The install script writes these automatically. Reference for manual setup or code review:
# DevSquad Sidecar DS_SIDECAR_ENABLED=true VITE_DS_SIDECAR_ENABLED="${DS_SIDECAR_ENABLED}" DS_SIDECAR_TINKER_ENABLED=true DS_SIDECAR_TINKER_USE_BATCH=true DS_SIDECAR_COMMANDS_ENABLED=true DS_SIDECAR_FAKE_CLOCK_ENABLED=true DS_SIDECAR_ALLOWED_IPS="127.0.0.1" DS_SIDECAR_BRANCH_URL=https://github.com/your-org/your-repo/tree/ DS_SIDECAR_LINK_MAIL=http://localhost:8025 DS_SIDECAR_LINK_ENVOYER=""
DS_SIDECAR_ALLOWED_IPS supports exact IPs, CIDR ranges, and prefix matching:
DS_SIDECAR_ALLOWED_IPS="127.0.0.1,192.168.1.0/24,10.0.0"
HEADER_BRANCH_NAME — on servers without git (e.g. Envoyer), inject via release hook:
cd {{ release }} sed -i '/HEADER_BRANCH_NAME/d' .env echo HEADER_BRANCH_NAME="{{ branch }}" >> .env
Frontend
Laravel apps (auto-inject enabled): no action needed. The Sidecar JS is injected automatically before </body> on every non-production HTML response.
Laravel apps with Vite (auto-inject disabled): if you set DS_SIDECAR_AUTO_INJECT_ASSETS=false in your .env, load Sidecar manually in your JavaScript entry point:
touch resources/js/devsquad-sidecar.js
// resources/js/devsquad-sidecar.js import { Sidecar } from "../../vendor/elitedevsquad/sidecar-laravel/resources/js/index.js"; if (import.meta.env.VITE_DS_SIDECAR_ENABLED === "true") { document.addEventListener("DOMContentLoaded", () => new Sidecar()); }
// resources/js/app.js import "./devsquad-sidecar";
Then build your assets:
npm run build
External apps (Next.js, Nuxt, etc.): the bundle is served by the Laravel route GET /__devsquad-sidecar/assets/js and reads window.__sidecarBaseUrl at runtime to prefix all API calls.
// e.g. pages/_app.js, app/layout.js, plugins/sidecar.js if (process.env.NODE_ENV !== 'production') { window.__sidecarBaseUrl = process.env.NEXT_PUBLIC_APP_URL ?? 'https://your-laravel-app.com'; const s = document.createElement('script'); s.src = window.__sidecarBaseUrl + '/__devsquad-sidecar/assets/js'; s.defer = true; document.head.appendChild(s); }