提交 a4553a5e 编写于 作者: 伟伟权

111. ApiResource attribute

上级 bd8a7b70
......@@ -43,3 +43,7 @@ MAILER_DSN=smtp://127.0.0.1:1025
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
###< symfony/messenger ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###
此差异已折叠。
......@@ -18,4 +18,6 @@ return [
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
];
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
patch_formats:
json: ['application/merge-patch+json']
swagger:
versions: [3]
nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null
api_platform:
resource: .
type: api_platform
prefix: /api
......@@ -2,6 +2,7 @@
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\PostRepository;
use App\Utils\DateTimeTrait;
use Doctrine\Common\Collections\ArrayCollection;
......@@ -12,6 +13,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Entity(repositoryClass=PostRepository::class)
* @ORM\HasLifecycleCallbacks
*/
#[ApiResource]
class Post
{
use DateTimeTrait;
......
......@@ -2,6 +2,7 @@
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
......@@ -12,6 +13,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
*/
#[ApiResource]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
......
{
"api-platform/api-pack": {
"version": "v1.3.0"
},
"api-platform/core": {
"version": "2.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "2.5",
"ref": "f132b33c43cf47b4451d91d2b57057eacb6b8e1d"
},
"files": [
"config/packages/api_platform.yaml",
"config/routes/api_platform.yaml",
"src/Entity/.gitignore"
]
},
"composer/package-versions-deprecated": {
"version": "1.11.99.2"
},
......@@ -115,6 +132,9 @@
"fakerphp/faker": {
"version": "v1.15.0"
},
"fig/link-util": {
"version": "1.2.0"
},
"friendsofphp/proxy-manager-lts": {
"version": "v1.0.5"
},
......@@ -161,6 +181,18 @@
"myclabs/deep-copy": {
"version": "1.10.2"
},
"nelmio/cors-bundle": {
"version": "1.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.5",
"ref": "6bea22e6c564fba3a1391615cada1437d0bde39c"
},
"files": [
"config/packages/nelmio_cors.yaml"
]
},
"nikic/php-parser": {
"version": "v4.10.5"
},
......@@ -223,6 +255,9 @@
"psr/event-dispatcher": {
"version": "1.0.0"
},
"psr/link": {
"version": "1.1.1"
},
"psr/log": {
"version": "1.1.4"
},
......@@ -609,6 +644,9 @@
"symfony/serializer": {
"version": "v5.3.2"
},
"symfony/serializer-pack": {
"version": "v1.0.4"
},
"symfony/service-contracts": {
"version": "v2.4.0"
},
......@@ -678,6 +716,9 @@
"symfony/var-exporter": {
"version": "v5.3.2"
},
"symfony/web-link": {
"version": "v5.3.4"
},
"symfony/web-profiler-bundle": {
"version": "3.3",
"recipe": {
......@@ -743,5 +784,8 @@
},
"willdurand/jsonp-callback-validator": {
"version": "v1.1.0"
},
"willdurand/negotiation": {
"version": "3.0.0"
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册