一键导入
add-provider
Load a resource from a non-Doctrine source (external API, command bus, DDD repository) for Show/Index/Update/Delete operations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Load a resource from a non-Doctrine source (external API, command bus, DDD repository) for Show/Index/Update/Delete operations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | add-provider |
| description | Load a resource from a non-Doctrine source (external API, command bus, DDD repository) for Show/Index/Update/Delete operations. |
| argument-hint | [ModelName] [Operation] |
| allowed-tools | AskUserQuestion, Bash, Read, Edit, Write, Glob, Grep |
Ask the user if not provided:
ModelName) and the target operation (Index, Show, Update, etc.){ModelName}{Operation}Provider (e.g. BookShowProvider).src/Provider/ (namespace App\Provider). For a DDD layout, ask for the infrastructure path (e.g. src/BoardGameBlog/Infrastructure/Sylius/State/Provider/).If the user only needs a different repository method, do not create a provider — suggest the operation flags instead:
new Show(
repositoryMethod: 'findOneBySlug',
repositoryArguments: ['slug' => "request.attributes.get('slug')"],
)
src/Provider/{ProviderName}.php
<?php
declare(strict_types=1);
namespace App\Provider;
use Sylius\Resource\Context\Context;
use Sylius\Resource\Context\Option\RequestOption;
use Sylius\Resource\Metadata\Operation;
use Sylius\Resource\State\ProviderInterface;
use Webmozart\Assert\Assert;
final class {ProviderName} implements ProviderInterface
{
public function __construct(
// TODO: inject the dependencies you need (QueryBus, HttpClient, Repository…)
) {
}
public function provide(Operation $operation, Context $context): object|array|null
{
$request = $context->get(RequestOption::class)?->request();
Assert::notNull($request);
// TODO: build and return the resource (or a collection for Index operations)
// return null if the resource cannot be found
return null;
}
}
Adjust the constructor and the provide() body with the real lookup logic. For an Index operation, return an iterable/paginator; for item operations (Show, Update, Delete), return a single object or null.
Edit src/Entity/{ModelName}.php — add the provider: argument on the target operation:
use App\Provider\{ProviderName};
new Show(provider: {ProviderName}::class),
If the resource is not a Doctrine entity, also ensure the operation does not rely on the default Doctrine processor — see /sylius-stack:add-processor to pair it with a custom processor.
bin/console cache:clear
bin/console sylius:debug:resource 'App\Entity\{ModelName}'
The operation's provider row should display your class FQCN.
/sylius-stack:add-processorread: false on the operation, no provider required.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