dbp / relay-base-course-bundle
v0.2.12
2024-07-11 20:09 UTC
Requires
- php: >=8.1
- ext-json: *
- api-platform/core: ^2.7.11 || ^3.2
- dbp/relay-core-bundle: ^0.1.171
- symfony/config: ^5.4 || ^6.4
- symfony/dependency-injection: ^5.4 || ^6.4
- symfony/framework-bundle: ^5.4 || ^6.4
- symfony/http-foundation: ^5.4 || ^6.4
- symfony/http-kernel: ^5.4 || ^6.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4
- phpstan/phpstan: ^1.8.11
- phpstan/phpstan-phpunit: ^1.2.2
- phpunit/phpunit: ^10.1
- symfony/browser-kit: ^5.4.11 || ^6.4
- symfony/error-handler: ^5.4 || ^6.4
- symfony/http-client: ^5.4.15 || ^6.4
- symfony/monolog-bridge: ^5.4 || ^6.4
- symfony/monolog-bundle: ^3.8
- symfony/phpunit-bridge: ^5.4.14 || ^6.4
- vimeo/psalm: ^5.22.2
This package is auto-updated.
Last update: 2024-09-23 07:37:01 UTC
README
DBP Relay API 服务器的基础 Symfony 扩展包。
集成到 Relay API 服务器
- 将包作为依赖项添加
composer require dbp/relay-base-course-bundle
- 将包添加到您的
config/bundles.php
... Dbp\Relay\BasePersonBundle\DbpRelayBaseCourseBundle::class => ['all' => true], ... ];
- 运行
composer install
清理缓存
课程提供者实现
为了使此包工作,您需要向您的应用程序添加一个实现 CourseProviderInterface 的服务。
示例
服务类
例如,创建一个服务 src/Service/CourseProvider.php
<?php namespace App\Service; use Dbp\Relay\BaseCourseBundle\API\CourseProviderInterface; use Dbp\Relay\BaseCourseBundle\Entity\Course; class CourseProvider implements CourseProviderInterface { public function getCourseById(string $identifier, array $options = []): ?Course { $course = new Course(); $course->setIdentifier($identifier); $course->setName('Field Theory'); $course->setDescription('News from field theory'); return $course; } ... }
服务配置
对于上面的示例服务,您需要在您的 src/Resources/config/services.yaml
中添加以下内容
Dbp\Relay\BaseCourseBundle\API\CourseProviderInterface: '@App\Service\CourseProvider'