← スキル一覧に戻る

symfony-skapi-repository
by Swoking
Claude Code plugin pour projets Symfony StarterKit
⭐ 0🍴 0📅 2026年1月19日
SKILL.md
name: symfony-sk:api-repository description: Create or modify Doctrine repositories. Use for custom database queries. allowed-tools: Read, Write, Edit, Glob, Grep
API Repository Skill
Mission
Create or modify Doctrine repositories for custom queries.
Location
api/src/Repository/<Name>Repository.php
Template
<?php
namespace App\Repository;
use App\Entity\<Name>;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<<Name>>
*/
class <Name>Repository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, <Name>::class);
}
/**
* @return <Name>[]
*/
public function findActiveByOwner(User $owner): array
{
return $this->createQueryBuilder('e')
->andWhere('e.owner = :owner')
->andWhere('e.isDeleted = 0')
->setParameter('owner', $owner)
->orderBy('e.createdAt', 'DESC')
->getQuery()
->getResult();
}
public function findOneByKey(string $key): ?<Name>
{
return $this->createQueryBuilder('e')
->andWhere('e.key = :key')
->andWhere('e.isDeleted = 0')
->setParameter('key', $key)
->getQuery()
->getOneOrNullResult();
}
}
Common Patterns
Find with conditions
public function findByStatus(string $status): array
{
return $this->createQueryBuilder('e')
->andWhere('e.status = :status')
->andWhere('e.isDeleted = 0')
->setParameter('status', $status)
->getQuery()
->getResult();
}
Count
public function countByOwner(User $owner): int
{
return $this->createQueryBuilder('e')
->select('COUNT(e.id)')
->andWhere('e.owner = :owner')
->andWhere('e.isDeleted = 0')
->setParameter('owner', $owner)
->getQuery()
->getSingleScalarResult();
}
With joins
public function findWithRelations(string $key): ?<Name>
{
return $this->createQueryBuilder('e')
->leftJoin('e.items', 'i')
->addSelect('i')
->andWhere('e.key = :key')
->setParameter('key', $key)
->getQuery()
->getOneOrNullResult();
}
Checklist
- Extends
ServiceEntityRepository - Type hints in PHPDoc
- Always filter
isDeleted = 0 - Use QueryBuilder (not raw SQL)
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です