Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

symfony

/symfony

Wspiera pracę z Symfony: jądro HTTP w PHP, Twig, Doctrine ORM, serwisy i MakerBundle przy budowie aplikacji PHP i usług webowych.

Repozytorium
Agent-Skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
01.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 01.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Wspiera pracę z Symfony: jądro HTTP w PHP, Twig, Doctrine ORM, serwisy i MakerBundle przy budowie aplikacji PHP i usług webowych.

Oryginalny opis (EN)

Expert Symfony assistance covering PHP HTTP kernel, Twig, Doctrine ORM, services, and MakerBundle. Use when building enterprise PHP applications and web services.

Jak działa

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Sekcje z nagłówków SKILL.md, w oryginale · 193 linii, 610 słów
Podgląd SKILL.md
---
name: symfony
description: Expert Symfony assistance covering PHP HTTP kernel, Twig, Doctrine ORM, services, and MakerBundle. Use when building enterprise PHP applications and web services.
---

# Symfony

Symfony is a decoupled, reusable PHP framework and set of components, emphasizing strict typing, PHP Attributes, and enterprise application architecture.

## When to Use

- **Enterprise PHP Web Applications & APIs**: High-performance backend architectures adhering strictly to design patterns.
- **Modular Enterprise Microservices**: Decoupled Symfony Components (HTTP Kernel, Console, Messenger, Serializer).
- **Asynchronous Message Queue Processing**: Handling event-driven message architectures with Symfony Messenger.
- **REST & GraphQL with API Platform**: Auto-generating compliant JSON:API and OpenAPI backends.

## Quick Start

```php
// src/Controller/ApiController.php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;

class ApiController extends AbstractController
{
    #[Route('/api/status', name: 'api_status', methods: ['GET'])]
    public function status(): JsonResponse
    {
        return $this->json(['status' => 'operational', 'framework' => 'symfony']);
    }
}
```

## Core Concepts

### Modern Attribute Routing & Dependency Injection

Writing controllers with PHP 8.2+ native attributes:

```php
namespace App\Controller;

use App\Repository\CustomerRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

#[Route('/api/v1/customers', name: 'api_customers_')]
class CustomerController extends AbstractController
{
    public function __construct(
        private readonly CustomerRepository $customerRepository
    ) {}

    #[Route('/{id}', name: 'show', methods: ['GET'])]
    public function show(int $id): JsonResponse
    {
        $customer = $this->customerRepository->find($id);

        if (!$customer) {
            return $this->json(['error' => 'Customer not found'], Response::HTTP_NOT_FOUND);
        }

        return $this->json($customer);
    }
}
```

### Doctrine ORM Entities & Attributes

Mapping database tables with native PHP attributes:

```php
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity]
#[ORM\Table(name: 'orders')]
class Order
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 255)]
    #[Assert\NotBlank]
    private string $reference;

    #[ORM\Column(type: 'decimal', precision: 10, scale: 2)]
    #[Assert\Positive]
    private string $totalAmount;

    public function getId(): ?int { return $this->id; }
    public function getReference(): string { return $this->reference; }
    public function setReference(string $ref): self { $this->reference = $ref; return $this; }
    public function getTotalAmount(): string { return $this->totalAmount; }
    public function setTotalAmount(string $amount): self { $this->totalAmount = $amount; return $this; }
}
```

### Symfony Messenger for Async Processing

Decoupled message dispatching and handling:

```php
namespace App\Message;

class ProcessInvoiceMessage
{
    public function __construct(public readonly int $orderId) {}
}

// In Message Handler:
namespace App\MessageHandler;

use App\Message\ProcessInvoiceMessage;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
class ProcessInvoiceHandler
{
    public function __invoke(ProcessInvoiceMessage $message): void
    {
        // Handle background invoice generation
    }
}
```

## Common Patterns

### Doctrine Entity Repository with Custom DQL Query

**Problem**: Generic `find()` methods unable to execute efficient joined queries.

**Solution**:
Write custom repository query builders:

```php
namespace App\Repository;

use App\Entity\Product;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

class ProductRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Product::class);
    }

    public function findTopInStock(int $limit = 10): array
    {
        return $this->createQueryBuilder('p')
            ->andWhere('p.stock > 0')
            ->orderBy('p.createdAt', 'DESC')
            ->setMaxResults($limit)
            ->getQuery()
            ->getResult();
    }
}
```

## Best Practices

**Do**:

- Target Symfony 7+ using PHP 8.2+ native attributes for routing, entities, and validation.
- Utilize Symfony Messenger for all asynchronous and queue-based background processing.
- Run `bin/console lint:container` and `bin/console lint:yaml` in CI/CD pipelines.
- Configure Symfony Cache with Redis for high-traffic session and doctrine result caching.

**Don't**:

- Put business logic inside controllers; encapsulate workflows in domain services.
- Run `cache:clear` directly on active production traffic; warm up cache in a staging release directory.
- Disable CSRF protection on state-changing web form submissions.

## Troubleshooting

| Error                                                                 | Cause                                                       | Solution                                                              |
| :-------------------------------------------------------------------- | :---------------------------------------------------------- | :-------------------------------------------------------------------- |
| `ServiceNotFoundException: You have requested a non-existent service` | Service not autowired or missing in `config/services.yaml`. | Ensure class is in `src/` and check autowiring in `services.yaml`.    |
| `No route found for "GET /path"`                                      | Route attribute missing or cache stale.                     | Clear Symfony cache: `php bin/console cache:clear`.                   |
| `DriverException: An exception occurred in the driver: Access denied` | Database credentials incorrect in `.env` or `DATABASE_URL`. | Update `.env.local` with valid database host, username, and password. |

## References

- [Symfony Documentation](https://symfony.com/)

Wersje

RepozytoriumWynikLicencja
Ta strona · G1Joshi/Agent-Skills100MIT
TerminalSkills/skills100Apache-2.0
ar4mirez/samuel100MIT

Migawka bazy z 13.11.2026 · wersja paczki 2b4c6775a926 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90php-symfony
    Pisze i przegląda kod Symfony zgodnie z oficjalnymi dobrymi praktykami, przy plikach PHP, YAML, XML i Twig.
  • 90symfony-backend
    Buduje backendy Symfony: bundle, Doctrine ORM, Twig, recepty Flex i komponent Messenger, z autowiringiem i mapowaniem Doctrine.
  • 100symfony-specialist
    Buduje aplikacje Symfony 6, 7 i 8, modeluje złożone relacje w Doctrine ORM, obsługuje zadania asynchroniczne w Messengerze i optymalizuje API Platform.
  • 100doctrine-patterns
    Stosuje dobre praktyki Doctrine ORM w Symfony: mapowanie encji, repozytoria, DQL i QueryBuilder z parametrami, zapobieganie N+1, relacje, zdarzenia cyklu życia, przetwarzanie wsadowe i migracje.
  • 90testing-symfony
    Wyznacza strategię testów dla Symfony 8.1 i PHP 8.5: pisanie testów, ocena pokrycia i konfiguracja testowania projektu.
  • 90project-analysis-symfony
    Analizuje projekt Symfony dogłębnie: kernel i bootstrap, kontener, routing i przepływ żądania, Doctrine, security, Messenger oraz typowe wzorce awarii.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.