بنقرة واحدة
add-responder
Return a non-standard HTTP response (PDF, XLSX, stream, binary) instead of the default HTML template.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Return a non-standard HTTP response (PDF, XLSX, stream, binary) instead of the default HTML template.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Implement the fix described in a GitHub issue and open a Pull Request that closes it
Apply the latest review feedback to a Pull Request and push it to the PR branch
Add an admin autocomplete form type for a Sylius Resource (translatable or not), optionally injected into another form via an extension
Add an admin FormType for an existing Sylius Resource
Add a Sylius admin grid for an existing Sylius Resource
Add a multiple images collection (OneToMany) to an existing Sylius Resource
| name | add-responder |
| description | Return a non-standard HTTP response (PDF, XLSX, stream, binary) instead of the default HTML template. |
| argument-hint | [ModelName] [Operation] |
| allowed-tools | AskUserQuestion, Bash, Read, Edit, Write, Glob, Grep |
Ask the user if not provided:
ModelName) and the target operation.{Purpose}Responder (e.g. ExportGridToXlsxResponder, BookPdfResponder).If the user only needs a custom redirect after a Create/Update/Delete, do not create a responder — suggest the operation flags:
new Create(
redirectToRoute: 'app_admin_author_show',
redirectArguments: ['id' => 'resource.getAuthor().getId()'],
)
If the user only needs extra variables in the default Twig template, use /sylius-stack:add-twig-context instead.
src/Responder/{ResponderName}.php
<?php
declare(strict_types=1);
namespace App\Responder;
use Sylius\Resource\Context\Context;
use Sylius\Resource\Metadata\Operation;
use Sylius\Resource\State\ResponderInterface;
use Symfony\Component\HttpFoundation\Response;
final readonly class {ResponderName} implements ResponderInterface
{
public function __construct(
// TODO: inject the services needed to build the response (renderer, http client, serializer…)
) {
}
public function respond(mixed $data, Operation $operation, Context $context): mixed
{
// TODO: transform $data into a Symfony Response and return it
// examples: new Response($body), new StreamedResponse(...), new BinaryFileResponse(...)
return new Response();
}
}
For a streaming / download response, follow this pattern (see also add-grid-export for a concrete CSV example):
use Symfony\Component\HttpFoundation\StreamedResponse;
$response = new StreamedResponse(function () use ($data) {
// write bytes to php://output
});
$response->headers->set('Content-Type', 'application/pdf');
$response->headers->set('Content-Disposition', 'attachment; filename="export.pdf"');
return $response;
Edit src/Entity/{ModelName}.php:
use App\Responder\{ResponderName};
new Index(
shortName: 'pdf',
responder: {ResponderName}::class,
),
Use a distinct shortName when the responder coexists with the default operation (e.g. HTML index + PDF export on the same resource).
bin/console cache:clear
bin/console sylius:debug:resource 'App\Entity\{ModelName}'
bin/console debug:router | grep {model_snake}
The operation's responder row should display your class FQCN and the corresponding route should appear.
/sylius-stack:add-grid-export (specialization of this pattern)/sylius-stack:add-twig-contextredirectToRoute / redirectArguments flags on the operation, no responder required.