Installed api platform.

This commit is contained in:
krzysiej
2022-06-09 11:46:15 +02:00
parent 61ab01f297
commit 00820715ea
10 changed files with 404 additions and 4 deletions

4
.env
View File

@@ -41,3 +41,7 @@ DATABASE_URL="mysql://root:root@127.0.0.1:3306/biblio?serverVersion=5.7&charset=
###> symfony/mailer ### ###> symfony/mailer ###
# MAILER_DSN=null://null # MAILER_DSN=null://null
###< symfony/mailer ### ###< symfony/mailer ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###

View File

@@ -7,10 +7,12 @@
"php": ">=8.0.2", "php": ">=8.0.2",
"ext-ctype": "*", "ext-ctype": "*",
"ext-iconv": "*", "ext-iconv": "*",
"api-platform/core": "^2.6",
"doctrine/annotations": "^1.0", "doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.6", "doctrine/doctrine-bundle": "^2.6",
"doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.12", "doctrine/orm": "^2.12",
"nelmio/cors-bundle": "^2.2",
"phpdocumentor/reflection-docblock": "^5.3", "phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.5", "phpstan/phpdoc-parser": "^1.5",
"sensio/framework-extra-bundle": "^6.1", "sensio/framework-extra-bundle": "^6.1",

341
composer.lock generated
View File

@@ -4,8 +4,169 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "38958ff5221180c36bc97324f82755b6", "content-hash": "7102d8819fdf13b2459783afe8ecb539",
"packages": [ "packages": [
{
"name": "api-platform/core",
"version": "v2.6.8",
"source": {
"type": "git",
"url": "https://github.com/api-platform/core.git",
"reference": "ff3aab5b196709c721960c0bb4f1d52759af737d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/api-platform/core/zipball/ff3aab5b196709c721960c0bb4f1d52759af737d",
"reference": "ff3aab5b196709c721960c0bb4f1d52759af737d",
"shasum": ""
},
"require": {
"doctrine/inflector": "^1.0 || ^2.0",
"fig/link-util": "^1.0",
"php": ">=7.1",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/container": "^1.0 || ^2.0",
"symfony/http-foundation": "^4.4 || ^5.1 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.1 || ^6.0",
"symfony/property-access": "^3.4.19 || ^4.4 || ^5.1 || ^6.0",
"symfony/property-info": "^3.4 || ^4.4 || ^5.2.1 || ^6.0",
"symfony/serializer": "^4.4 || ^5.1 || ^6.0",
"symfony/web-link": "^4.4 || ^5.1 || ^6.0",
"willdurand/negotiation": "^2.0.3 || ^3.0"
},
"conflict": {
"doctrine/common": "<2.7",
"doctrine/dbal": "<2.10",
"doctrine/mongodb-odm": "<2.2",
"doctrine/persistence": "<1.3"
},
"require-dev": {
"behat/behat": "^3.1",
"behat/mink": "^1.9@dev",
"doctrine/annotations": "^1.7",
"doctrine/cache": "^1.11 || ^2.1",
"doctrine/common": "^2.11 || ^3.0",
"doctrine/data-fixtures": "^1.2.2",
"doctrine/dbal": "^2.6 || ^3.0",
"doctrine/doctrine-bundle": "^1.12 || ^2.0",
"doctrine/mongodb-odm": "^2.2",
"doctrine/mongodb-odm-bundle": "^4.0",
"doctrine/orm": "^2.6.4",
"elasticsearch/elasticsearch": "^6.0 || ^7.0",
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
"friends-of-behat/mink-extension": "^2.2",
"friends-of-behat/symfony-extension": "^2.1",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"jangregor/phpstan-prophecy": "^1.0",
"justinrainbow/json-schema": "^5.2.1",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.1",
"phpdocumentor/type-resolver": "^0.3 || ^0.4 || ^1.4",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"ramsey/uuid": "^3.7 || ^4.0",
"ramsey/uuid-doctrine": "^1.4",
"soyuka/contexts": "dev-main",
"soyuka/stubs-mongodb": "^1.0",
"symfony/asset": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/browser-kit": "^4.4 || ^5.1 || ^6.0",
"symfony/cache": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/config": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/console": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/css-selector": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/debug": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/dependency-injection": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/doctrine-bridge": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/dom-crawler": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/expression-language": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/finder": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/form": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.1 || ^6.0",
"symfony/http-client": "^4.4 || ^5.1 || ^6.0",
"symfony/mercure-bundle": "*",
"symfony/messenger": "^4.4 || ^5.1 || ^6.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0",
"symfony/routing": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/security-bundle": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/security-core": "^4.4 || ^5.1 || ^6.0",
"symfony/twig-bundle": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/validator": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"symfony/web-profiler-bundle": "^4.4 || ^5.1 || ^6.0",
"symfony/yaml": "^3.4 || ^4.4 || ^5.1 || ^6.0",
"twig/twig": "^1.42.3 || ^2.12 || ^3.0",
"webonyx/graphql-php": "^14.0"
},
"suggest": {
"doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",
"elasticsearch/elasticsearch": "To support Elasticsearch.",
"guzzlehttp/guzzle": "To use the HTTP cache invalidation system.",
"ocramius/package-versions": "To display the API Platform's version in the debug bar.",
"phpdocumentor/reflection-docblock": "To support extracting metadata from PHPDoc.",
"psr/cache-implementation": "To use metadata caching.",
"ramsey/uuid": "To support Ramsey's UUID identifiers.",
"symfony/cache": "To have metadata caching when using Symfony integration.",
"symfony/config": "To load XML configuration files.",
"symfony/expression-language": "To use authorization features.",
"symfony/security": "To use authorization features.",
"symfony/twig-bundle": "To use the Swagger UI integration.",
"symfony/uid": "To support Symfony UUID/ULID identifiers.",
"symfony/web-profiler-bundle": "To use the data collector.",
"webonyx/graphql-php": "To support GraphQL."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.6.x-dev"
},
"symfony": {
"require": "^3.4 || ^4.4 || ^5.1 || ^6.0"
}
},
"autoload": {
"psr-4": {
"ApiPlatform\\Core\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kévin Dunglas",
"email": "kevin@dunglas.fr",
"homepage": "https://dunglas.fr"
}
],
"description": "Build a fully-featured hypermedia or GraphQL API in minutes!",
"homepage": "https://api-platform.com",
"keywords": [
"Hydra",
"JSON-LD",
"api",
"graphql",
"hal",
"jsonapi",
"openapi",
"rest",
"swagger"
],
"support": {
"issues": "https://github.com/api-platform/core/issues",
"source": "https://github.com/api-platform/core/tree/v2.6.8"
},
"funding": [
{
"url": "https://tidelift.com/funding/github/packagist/api-platform/core",
"type": "tidelift"
}
],
"time": "2022-01-11T10:29:54+00:00"
},
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "1.13.2", "version": "1.13.2",
@@ -1443,6 +1604,67 @@
], ],
"time": "2021-10-11T09:18:27+00:00" "time": "2021-10-11T09:18:27+00:00"
}, },
{
"name": "fig/link-util",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/link-util.git",
"reference": "10e52348a2e9ad4581f2bf3e16458f0861a88c6a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/link-util/zipball/10e52348a2e9ad4581f2bf3e16458f0861a88c6a",
"reference": "10e52348a2e9ad4581f2bf3e16458f0861a88c6a",
"shasum": ""
},
"require": {
"php": ">=8.0.0",
"psr/link": "^1.1.0 | ^2.0.0"
},
"provide": {
"psr/link-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^2.3.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Fig\\Link\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common utility implementations for HTTP links",
"keywords": [
"http",
"http-link",
"link",
"psr",
"psr-13",
"rest"
],
"support": {
"issues": "https://github.com/php-fig/link-util/issues",
"source": "https://github.com/php-fig/link-util/tree/1.2.0"
},
"time": "2021-03-11T23:09:19+00:00"
},
{ {
"name": "friendsofphp/proxy-manager-lts", "name": "friendsofphp/proxy-manager-lts",
"version": "v1.0.12", "version": "v1.0.12",
@@ -2070,6 +2292,67 @@
], ],
"time": "2022-05-10T09:36:00+00:00" "time": "2022-05-10T09:36:00+00:00"
}, },
{
"name": "nelmio/cors-bundle",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/nelmio/NelmioCorsBundle.git",
"reference": "0ee5ee30b0ee08ea122d431ae6e0ddeb87f035c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/0ee5ee30b0ee08ea122d431ae6e0ddeb87f035c0",
"reference": "0ee5ee30b0ee08ea122d431ae6e0ddeb87f035c0",
"shasum": ""
},
"require": {
"symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0"
},
"require-dev": {
"mockery/mockery": "^1.2",
"symfony/phpunit-bridge": "^4.3 || ^5.0 || ^6.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Nelmio\\CorsBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nelmio",
"homepage": "http://nelm.io"
},
{
"name": "Symfony Community",
"homepage": "https://github.com/nelmio/NelmioCorsBundle/contributors"
}
],
"description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application",
"keywords": [
"api",
"cors",
"crossdomain"
],
"support": {
"issues": "https://github.com/nelmio/NelmioCorsBundle/issues",
"source": "https://github.com/nelmio/NelmioCorsBundle/tree/2.2.0"
},
"time": "2021-12-01T09:34:27+00:00"
},
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
"version": "2.2.0", "version": "2.2.0",
@@ -8324,6 +8607,62 @@
"source": "https://github.com/webmozarts/assert/tree/1.10.0" "source": "https://github.com/webmozarts/assert/tree/1.10.0"
}, },
"time": "2021-03-09T10:59:23+00:00" "time": "2021-03-09T10:59:23+00:00"
},
{
"name": "willdurand/negotiation",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/willdurand/Negotiation.git",
"reference": "68e9ea0553ef6e2ee8db5c1d98829f111e623ec2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/willdurand/Negotiation/zipball/68e9ea0553ef6e2ee8db5c1d98829f111e623ec2",
"reference": "68e9ea0553ef6e2ee8db5c1d98829f111e623ec2",
"shasum": ""
},
"require": {
"php": ">=7.1.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Negotiation\\": "src/Negotiation"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "William Durand",
"email": "will+git@drnd.me"
}
],
"description": "Content Negotiation tools for PHP provided as a standalone library.",
"homepage": "http://williamdurand.fr/Negotiation/",
"keywords": [
"accept",
"content",
"format",
"header",
"negotiation"
],
"support": {
"issues": "https://github.com/willdurand/Negotiation/issues",
"source": "https://github.com/willdurand/Negotiation/tree/3.1.0"
},
"time": "2022-01-30T20:08:53+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [

View File

@@ -14,4 +14,6 @@ return [
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Symfony\UX\Dropzone\DropzoneBundle::class => ['all' => true], Symfony\UX\Dropzone\DropzoneBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
]; ];

View File

@@ -0,0 +1,7 @@
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
patch_formats:
json: ['application/merge-patch+json']
swagger:
versions: [3]

View File

@@ -0,0 +1,10 @@
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

View File

@@ -0,0 +1,4 @@
api_platform:
resource: .
type: api_platform
prefix: /api

View File

@@ -2,9 +2,11 @@
namespace App\Entity; namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\FileRepository; use App\Repository\FileRepository;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: FileRepository::class)] #[ORM\Entity(repositoryClass: FileRepository::class)]
class File class File
{ {

View File

@@ -1,4 +1,18 @@
{ {
"api-platform/core": {
"version": "2.6",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.5",
"ref": "05b57782a78c21a664a42055dc11cf1954ca36bb"
},
"files": [
"./config/packages/api_platform.yaml",
"./config/routes/api_platform.yaml",
"./src/Entity/.gitignore"
]
},
"doctrine/annotations": { "doctrine/annotations": {
"version": "1.13", "version": "1.13",
"recipe": { "recipe": {
@@ -77,6 +91,9 @@
"egulias/email-validator": { "egulias/email-validator": {
"version": "3.1.2" "version": "3.1.2"
}, },
"fig/link-util": {
"version": "1.2.0"
},
"friendsofphp/proxy-manager-lts": { "friendsofphp/proxy-manager-lts": {
"version": "v1.0.12" "version": "v1.0.12"
}, },
@@ -98,6 +115,18 @@
"monolog/monolog": { "monolog/monolog": {
"version": "2.6.0" "version": "2.6.0"
}, },
"nelmio/cors-bundle": {
"version": "2.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.5",
"ref": "6bea22e6c564fba3a1391615cada1437d0bde39c"
},
"files": [
"./config/packages/nelmio_cors.yaml"
]
},
"nikic/php-parser": { "nikic/php-parser": {
"version": "v4.13.2" "version": "v4.13.2"
}, },
@@ -544,5 +573,8 @@
}, },
"webmozart/assert": { "webmozart/assert": {
"version": "1.10.0" "version": "1.10.0"
},
"willdurand/negotiation": {
"version": "3.1.0"
} }
} }

View File

@@ -18,10 +18,9 @@
<tr> <tr>
<th></th> <th></th>
<th>Title</th> <th>Title</th>
<th>Language</th>
<th>Description</th> <th>Description</th>
<th>Publisher</th> <th>Publisher</th>
<th>Publish_date</th> <th>Publish date</th>
<th>actions</th> <th>actions</th>
</tr> </tr>
</thead> </thead>
@@ -38,7 +37,6 @@
</td> </td>
<td><a href="{{ path('app_book_show', {'id': book.id}) }}" <td><a href="{{ path('app_book_show', {'id': book.id}) }}"
class="text-decoration-none">{{ book.title }}</a></td> class="text-decoration-none">{{ book.title }}</a></td>
<td>{{ book.language }}</td>
<td>{{ book.description | slice(0, 200) }}</td> <td>{{ book.description | slice(0, 200) }}</td>
<td>{{ book.publisher }}</td> <td>{{ book.publisher }}</td>
<td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td> <td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td>