// 57 tips tagged "php"
Every language evolves — callbacks become async/await, class components become hooks, jQuery becomes vanilla JS, and var becomes const. Tell Claude to read your legacy code and upgrade it to modern patterns, one module at a time, while keeping the behavior identical and the tests passing.
Point Claude at untyped code and tell it to add types — TypeScript annotations to JavaScript, type hints to Python, PHPDoc blocks to PHP, or generics to Java. Claude reads the actual usage, infers the correct types from context, and adds them without changing any behavior.
When you need to port code from one language to another — a Python script to JavaScript, a Bash utility to PHP, or a Ruby service to Go — Claude translates the logic while rewriting it idiomatically for the target language, using its conventions, libraries, and patterns instead of a line-by-line copy.
Point Claude at code in one language and tell it to rewrite in another — Python to Go, PHP to JavaScript, Ruby to Rust — and it translates not just the syntax but the idioms, using the target language's patterns, standard library, and conventions instead of a literal word-for-word port.
Stop wrestling with regex syntax — describe the pattern you want in plain English and Claude writes the expression, explains every part, and tests it against your sample data so you know it works before you paste it into production code.
When your app throws an error, paste the full stack trace into Claude Code — it reads every frame, opens the source files at the exact lines referenced, traces the actual cause, and fixes the bug, not just the symptom.
Point Claude at undocumented functions and it reads the implementation to write accurate JSDoc, PHPDoc, or docstring comments — including parameter descriptions, return types, thrown exceptions, and usage examples that actually match what the code does.
Point Claude at untyped files and ask it to add type annotations — it infers types from usage patterns, function signatures, and call sites across your codebase, then adds TypeScript types, Python hints, or PHPDoc blocks in place.
Before asking Claude to scaffold a new feature, point it at your existing code first — it will match your naming, structure, error handling, and test patterns exactly rather than defaulting to framework boilerplate.
Generate typed, immutable Data Transfer Objects with validation and factory methods for your API endpoints in PHP or TypeScript.
Let Claude write custom PHPStan and Larastan rules that enforce your team's conventions, complete with AST visitor logic and config registration.
Scaffold single-database or database-per-tenant multi-tenancy in Laravel with global scopes, middleware, queue context, and tenant-aware caching.