custom-php-running-tinker

Runs throwaway PHP and Laravel code through Sail artisan tinker against the booted application.

1|Updated Apr 3, 2021
One-click install
npx skills add https://github.com/NaoyaMiyagawa/dotfiles --skill custom-php-running-tinker-naoyamiyagawa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: custom-php-running-tinker
Source: https://github.com/NaoyaMiyagawa/dotfiles/tree/main/.ai/skills/custom-php-running-tinker
Command: npx skills add https://github.com/NaoyaMiyagawa/dotfiles --skill custom-php-running-tinker-naoyamiyagawa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing a quick PHP snippet or inspecting a Laravel model normally requires writing a throwaway script, temporary route, or one-off command. This Skill evaluates code directly against the booted application inside the Sail Docker stack, so extensions, environment variables, and database connections match the real project. ## Core Features & Use Cases - Non-interactive execution: Runs snippets via sail artisan tinker --execute so commands exit cleanly without hanging on an interactive REPL. - Environment fidelity: Executes inside Sail containers, ensuring PHP extensions, .env values, and services match the project instead of the host machine. - Use Case: You want to check how many users exist or inspect a config value. Run ./vendor/bin/sail artisan tinker --execute="User::count();" and get the result immediately without creating any files. ## Quick Start Ask the assistant to run a PHP snippet like counting User records through Sail artisan tinker against the running Laravel app.

Frequently Asked Questions about custom-php-running-tinker

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a quick PHP snippet in a Laravel Sail project?

Run the snippet through `./vendor/bin/sail artisan tinker --execute="your code"` so it executes inside the Sail containers. This ensures PHP extensions, environment variables, and database connections match the project rather than the host machine.

How to inspect a Laravel model without writing a test or script?

Use tinker in non-interactive mode, for example `./vendor/bin/sail artisan tinker --execute="User::count();"`. Use `dump()` or `dd()` to surface values, since bare expressions are not echoed in non-interactive mode.

Why does artisan tinker hang when run without --execute?

Without the `--execute` flag, tinker opens an interactive REPL that waits for input and never exits. Always pass `--execute` for one-off snippets, or pipe multi-line code via stdin, so the command terminates after running.

Can I run php artisan tinker on the host instead of through Sail?

No, running tinker on the host uses the wrong environment with mismatched PHP extensions, `.env` values, and database connections. Always go through `./vendor/bin/sail`, and if Sail or Docker is unavailable, stop rather than falling back to host PHP.

When should I write a Pest test instead of using tinker?

Use tinker only for throwaway exploration like inspecting models or checking framework behavior. Any assertion that verifies expected behavior belongs in a Pest test so it is repeatable and enforced in the test suite.