add rest api
This commit is contained in:
parent
2b5d943116
commit
d92a63fd7d
15 changed files with 2415 additions and 281 deletions
|
@ -1,10 +1,13 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use ApiPlatform\Symfony\Bundle\ApiPlatformBundle;
|
||||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
|
||||
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
|
||||
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
|
||||
use Nelmio\CorsBundle\NelmioCorsBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\MakerBundle\MakerBundle;
|
||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||
use Symfony\Bundle\TwigBundle\TwigBundle;
|
||||
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
|
||||
|
||||
|
@ -32,4 +35,13 @@ return [
|
|||
'dev' => true,
|
||||
'test' => true,
|
||||
],
|
||||
SecurityBundle::class => [
|
||||
'all' => true,
|
||||
],
|
||||
NelmioCorsBundle::class => [
|
||||
'all' => true,
|
||||
],
|
||||
ApiPlatformBundle::class => [
|
||||
'all' => true,
|
||||
],
|
||||
];
|
||||
|
|
20
config/packages/api_platform.php
Normal file
20
config/packages/api_platform.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->extension('api_platform', [
|
||||
'title' => 'Hello API Platform',
|
||||
'version' => '1.0.0',
|
||||
'defaults' => [
|
||||
'stateless' => true,
|
||||
'cache_headers' => [
|
||||
'vary' => [
|
||||
'Content-Type',
|
||||
'Authorization',
|
||||
'Origin',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
};
|
33
config/packages/nelmio_cors.php
Normal file
33
config/packages/nelmio_cors.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->extension('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,
|
||||
],
|
||||
]);
|
||||
};
|
40
config/packages/security.php
Normal file
40
config/packages/security.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->extension('security', [
|
||||
'password_hashers' => [
|
||||
PasswordAuthenticatedUserInterface::class => 'auto',
|
||||
],
|
||||
'providers' => [
|
||||
'users_in_memory' => [
|
||||
'memory' => null,
|
||||
],
|
||||
],
|
||||
'firewalls' => [
|
||||
'dev' => [
|
||||
'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
|
||||
'security' => false,
|
||||
],
|
||||
'main' => [
|
||||
'lazy' => true,
|
||||
'provider' => 'users_in_memory',
|
||||
],
|
||||
],
|
||||
'access_control' => null,
|
||||
]);
|
||||
if ($containerConfigurator->env() === 'test') {
|
||||
$containerConfigurator->extension('security', [
|
||||
'password_hashers' => [
|
||||
PasswordAuthenticatedUserInterface::class => [
|
||||
'algorithm' => 'auto',
|
||||
'cost' => 4,
|
||||
'time_cost' => 3,
|
||||
'memory_cost' => 10,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
};
|
8
config/routes/api_platform.php
Normal file
8
config/routes/api_platform.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
|
||||
return static function (RoutingConfigurator $routingConfigurator): void {
|
||||
$routingConfigurator->import('.', 'api_platform')
|
||||
->prefix('/api');
|
||||
};
|
7
config/routes/security.php
Normal file
7
config/routes/security.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
|
||||
return static function (RoutingConfigurator $routingConfigurator): void {
|
||||
$routingConfigurator->import('security.route_loader.logout', 'service');
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue