---
title: 'Check Laravel production with a read-only Tinker snippet'
description: 'Verify the Laravel environment, database connection, and table state with a read-only Tinker snippet before any production maintenance work.'
canonical_url: 'https://larabench.com/laravel-tinker-workflows/safe-laravel-production-check'
md_url: 'https://larabench.com/laravel-tinker-workflows/safe-laravel-production-check.md'
last_updated: '2026-07-28'
---
# Check Laravel production with a read-only Tinker snippet

> Verify the Laravel environment, database connection, and table state with a read-only Tinker snippet before any production maintenance work.

## Direct Answer

Start with a read-only snippet, verify the target environment, and avoid model methods that can trigger writes or side effects.

## When To Use This

Use this for small facts: which config value is loaded, whether a table exists, which database connection is active, or whether a queue setting matches deployment expectations.

## Terminal Approach

```bash
php artisan about
php artisan tinker --execute="dump([app()->environment(), config('database.default')]);"
```

## LaraBench Approach

Choose a connection labeled Production and confirm the run before it executes. Run Code dry run adds write protection to Tinker snippets; Artisan commands do not use the Tinker dry-run wrapper.

## Snippet

```php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return [
    'app' => config('app.name'),
    'env' => app()->environment(),
    'database' => config('database.default'),
    'users_table_exists' => Schema::hasTable('users'),
    'users_table_has_rows' => Schema::hasTable('users')
        ? DB::table('users')->exists()
        : null,
];
```

## Expected Result

The output should prove the app, environment, default database connection, and table state without exposing user records. The final value is a boolean that confirms basic database access.

## Troubleshooting

- If the environment is wrong, stop and fix the connection target before running another snippet.
- If the table check fails, inspect the selected database connection and migration state.
- If a snippet needs application models, check observers and accessors before assuming the code is read-only.

## Safety Notes

Tinker executes real PHP inside the app. A snippet that looks like inspection can still write if it calls domain methods, lazy accessors, event dispatchers, or external services.

## Related Sources

- [Laravel configuration documentation](https://laravel.com/docs/13.x/configuration)
- [Laravel database documentation](https://laravel.com/docs/13.x/database)
- [LaraBench Run Safety docs](https://larabench.com/docs/advanced-usage/run-safety)

## Related Workflows

- [Run Laravel Tinker over SSH](https://larabench.com/laravel-tinker-workflows/run-laravel-tinker-over-ssh)
- [Inspect Laravel config and service container bindings](https://larabench.com/laravel-tinker-workflows/inspect-laravel-config-and-services)

## Canonical Page

- [HTML page](https://larabench.com/laravel-tinker-workflows/safe-laravel-production-check)
- [Markdown mirror](https://larabench.com/laravel-tinker-workflows/safe-laravel-production-check.md)

## Glossary

- [Laravel workflow glossary](https://larabench.com/docs/reference/glossary)

## Sitemap

See the full [sitemap](https://larabench.com/sitemap.md) for all public pages.
