/php:php-sql-conventionsfrom php
Provides conventions for writing SQL queries in PHP with Doctrine DBAL, including query direction, nowdoc formatting, SELECT formatting, and JOIN ordering.
Ships in php. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Conventions for SQL queries written in PHP code (Doctrine DBAL).
IMPORTANT: Always start queries from the known/main entity and navigate to related entities via JOINs.
When you have access to a specific entity (via ID or UUID), start the query from that entity's table and JOIN towards the data you need.
Context: You have a $orderId and want to fetch associated buyers.
// Start from orders (known entity) -> navigate to buyer
FROM orders o
INNER JOIN shipping_group sg ON sg.id = o.shipping_group_id
INNER JOIN shipping_item si ON si.shipping_group_id = sg.id
INNER JOIN buyer b ON b.id = si.buyer_id
WHERE o.id = :order_id
// Start from buyer (unknown) -> navigate back to orders
FROM buyer b
INNER JOIN shipping_item si ON si.buyer_id = b.id
INNER JOIN shipping_group sg ON sg.id = si.shipping_group_id
INNER JOIN orders o ON o.shipping_group_id = sg.id
WHERE o.id = :order_id
IMPORTANT: Follow PER Coding Style - Section 10 for nowdoc/heredoc formatting.
See code-conventions skill for complete PER rules.
<<<'SQL') - never heredoc (<<<SQL) for SQL queries:param) instead of variable interpolation$data = $connection->executeQuery(
<<<'SQL'
SELECT b.id, b.name
FROM buyer b
WHERE b.uuid = :uuid
SQL,
[
'uuid' => $uuid,
],
[
'uuid' => UuidType::NAME,
],
)->fetchAssociative();
One column per line for readability:
<<<'SQL'
SELECT
b.id,
b.first_name,
b.last_name,
BIN_TO_UUID(b.uuid) as uuid
FROM buyer b
SQL
b for buyer, o for orders)AS for column aliases: BIN_TO_UUID(b.uuid) AS uuidINNER JOIN, LEFT JOIN)FROM orders o
INNER JOIN shipping_group sg ON sg.id = o.shipping_group_id
INNER JOIN shipping_item si ON si.shipping_group_id = sg.id
LEFT JOIN buyer b ON b.id = si.buyer_id
| Rule | Description |
|---|---|
| Query direction | Start from known entity, JOIN to needed data |
| Nowdoc syntax | Use <<<'SQL' (nowdoc), never <<<SQL (heredoc) |
| Nowdoc format | See code-conventions for PER rules |
| Column listing | One per line for multi-column SELECT |
| Table aliases | Short, meaningful, always prefixed |
| JOIN order | Follow logical relationship path |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sql-conventions, doctrine-dbal, php-sql, nowdoc, query-direction, join-ordering
npx claudepluginhub fabiensalles/claude-marketplace --plugin php10 skills in this plugin
/php-8-0ACTIVATE when calling a constructor, method or function with four or more arguments in a PHP 8.0+ project — value objects, contract requests, factories, projections, test fixtures. Covers: mandatory named arguments from the fourth argument on. DO NOT use for: calls of three arguments or fewer, PHP 8.1 features (see php-8-1), PHP 8.2 features (see php-8-2), PHP 8.3 features (see php-8-3)./php-8-1ACTIVATE when passing a method as a callback in a PHP 8.1+ project — event listeners, validator callbacks, Twig functions, array_map/usort callables. Covers: mandatory first-class callable syntax (`$this` method reference with `(...)`) over array/string callables. DO NOT use for: general PHP syntax, PHP 8.2 features (see php-8-2), PHP 8.3 features (see php-8-3)./php-Other plugins' skills for the same job