- How do I install spatie/laravel-web-tinker in my Laravel application?
- Install it as a dev dependency with composer require spatie/laravel-web-tinker --dev, then run php artisan web-tinker:install to publish the frontend assets. The install is complete at that point: there are no migrations, no external services and no credentials to configure. If you want to tweak the defaults, publish the config file with php artisan vendor:publish --provider="Spatie\WebTinker\WebTinkerServiceProvider" --tag="config".
- Is spatie/laravel-web-tinker safe to run in production?
- No. The package executes arbitrary PHP with the full privileges of your application process, which means it can read environment secrets, query the database and touch the filesystem or outbound network. Installing with --dev keeps it out of your production artifacts, and by default the route is only enabled when APP_ENV is local. Never enable it on production or on any environment that handles real-world data.
- Which Laravel and PHP versions does spatie/laravel-web-tinker support?
- The changelog shows coverage for Laravel 10, 11, 12 and 13, and PHP 8 or higher has been required since version 1.7.7. Spatie tends to ship framework support in minor releases, so check the Composer constraints on Packagist before a major upgrade. Because the package is pulled in with --dev, it will not block a production deploy even if you lag behind.
- How do I change the URL path where the web tinker page is available?
- Publish the config file with the web-tinker config tag, then edit the path key in config/web-tinker.php. The package registers its own route with the middleware it needs, so you do not have to add anything to your routes files. Changing the default path is a reasonable extra hurdle, but it is not a substitute for the Gate or middleware controls.
- How do I restrict who can access the web tinker route?
- The package ships three layers you can use: the enabled flag, which defaults to APP_ENV === 'local'; a viewWebTinker Gate; and a middleware key in the config. Replace or extend that middleware stack with auth, an IP allowlist, VPN-only ingress or basic auth if you need network-level controls. The middleware key is the main governance lever, so decide who owns it before enabling the route anywhere shared.
- What is the difference between laravel-web-tinker and php artisan tinker?
- Both run on PsySH, the engine behind php artisan tinker, so the code you execute behaves the same way. The difference is purely ergonomic: web tinker gives you a browser page where results stay visible, so you can make a few edits and re-run without copy/pasting back and forth between an editor and a terminal. It also includes light and dark themes, but it is not a debugger, profiler or step-through tool.
- Can I use web tinker on staging or a preview environment where APP_ENV is not local?
- By default the route is disabled outside local, so staging and preview hosts will not expose it unless you deliberately change the enabled setting. If you do enable it there, remember that staging data is often production-like, so pair it with the viewWebTinker Gate, restrictive middleware and network controls such as an IP allowlist. Add a CI test that asserts the route is not registered in production builds rather than relying on APP_ENV alone. Treat the answer as a documented policy decision, not a per-developer judgement call.
- Does spatie/laravel-web-tinker work with Laravel Octane or Swoole?
- There is no explicit validation for long-lived workers, so treat Octane and Swoole as untested territory. PsySH shell state would persist inside a resident worker, which raises the possibility of state bleeding between requests and gradual memory growth. If you run Octane, test for both problems explicitly or keep tinkering in the terminal instead.
- How do I customize how web tinker formats and displays output?
- Bind your own implementation of the OutputModifier interface through the output_modifier key in config/web-tinker.php. That interface is the package's only real extension point, and it is limited to formatting the output that comes back from PsySH. Anything beyond presentation, such as adding commands or changing execution behaviour, means forking the package.
- What are the alternatives to spatie/laravel-web-tinker?
- The closest equivalents are php artisan tinker over SSH, which is already part of Laravel, and Tinkerwell, a desktop app that connects to your project without exposing a route. For inspection rather than execution, Laravel Telescope or Clockwork cover request, query and log debugging. Web tinker's niche is a local-only convenience page, so if you need remote access, a terminal session or a secured tunnel is usually the better trade-off.