- Can I use this bundle in Symfony 6 or 7 projects, or is it only for Symfony 4/5?
- This bundle officially supports Symfony 4 and 5 only. While it *might* work with Symfony 6/7 due to PHP 7.1+ compatibility, it hasn’t been tested. You’d need to manually patch container compilation changes (e.g., Symfony 6’s attribute-based services) or explore alternatives like `symfony/debug-pack` for modern support.
- How do I install and enable the PsySH bundle in Symfony?
- Run `composer require alexmasterov/psysh-bundle`, then add `PsyshBundle::class` to your `config/bundles.php` under the `'dev' => true` key. No additional steps are needed—just run `php bin/console psysh:shell` to start the REPL.
- What’s the best way to inject services or controllers into the PsySH shell?
- Use YAML configuration under `services:` with the `psysh.variable` tag. For example, tag a controller or service with `tags: ['psysh.variable']` to auto-load it. You can also manually inject variables via `psysh:` config, like `variables: ['@service', { db: PDO }]`.
- Is this bundle safe for production environments?
- No, this bundle is **not** production-safe. The PsySH REPL exposes sensitive data (e.g., services, variables) and should only be used in development. For production debugging, use Symfony’s `debug:container` or IDE tools like Xdebug instead.
- How do I customize PsySH’s behavior, like colors or history settings?
- Configure PsySH via `config/packages/psysh.yaml`. Options include `color_mode` (auto/forced/disabled), `history_size`, and `variables` for preloaded services. Refer to the [PsySH wiki](https://github.com/bobthecow/psysh/wiki/Config-options) for all available settings.
- Will this bundle conflict with other PsySH-based tools or Symfony components?
- Potential conflicts may arise with `psy/psysh` (v0.9 dependency) if other packages use newer versions. For Symfony, ensure no other bundle overrides the `psysh:shell` command. Test in a staging environment before full adoption.
- How do I debug Doctrine entities or database connections in PsySH?
- Inject the Doctrine connection or entity manager via YAML config: `variables: ['@doctrine.dbal.connection', '@doctrine.orm.entity_manager']`. Then use PsySH commands like `ls` to list available variables or `$db->query('SELECT * FROM users')` for direct queries.
- Are there alternatives to this bundle for Symfony debugging?
- Yes. For Symfony 6/7, consider `symfony/debug-pack` (includes `debug:container` and `debug:autowiring`). For REPL needs, `symfony/var-dumper` + IDE debugging (Xdebug) is a lightweight alternative. If you need PsySH specifically, check `symfony/console`’s built-in REPL features.
- How do I restrict access to sensitive variables (e.g., API keys) in PsySH?
- Avoid injecting sensitive services/variables directly. Use whitelisting in `psysh:` config (e.g., only allow `@service` but not `@security.token_storage`). For extra safety, manually unset variables after debugging: `$GLOBALS = array_diff_key($GLOBALS, ['sensitive_key' => true]);`.
- Does this bundle support Symfony’s Messenger component or attribute-based routing debugging?
- No, this bundle lacks support for Symfony 6+ features like Messenger or attribute-based routing. It’s designed for Symfony 4/5 and PsySH v0.9, which don’t include these modern components. For those, use Symfony’s native tools or upgrade PsySH to v0.12.x manually.