Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📦 Base classes and helper services to build API application via Symfony.

License

NotificationsYou must be signed in to change notification settings

stfalcon-studio/ApiBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 Base classes and helper services to build API application via Symfony.

Scrutinizer Quality ScoreBuild StatusCodeCovLicenseLatest Stable VersionTotal DownloadsStyleCI

Installation

composer req stfalcon-studio/api-bundle

Add next dependencies if you want to use JWT auth

composer req gesdinet/jwt-refresh-token-bundlecomposer req lexik/jwt-authentication-bundle

Check theconfig/bundles.php file

By default, Symfony Flex adds this bundle to theconfig/bundles.php file.In case when you ignoredcontrib-recipe during bundle installation it would not be added. In this case add the bundle manually.

# config/bundles.phpreturn [// Other bundles...StfalconStudio\ApiBundle\StfalconApiBundle::class => ['all' =>true],// Other bundles...];

Set Up Steps

Add mappings to Doctrine ORM config

doctrine:orm:mappings:StfalconApiBundle:~

Set up a directory for JSON schemas

The default directory is./src/Json/Schema/. Or you can change it via bundle configuration.

stfalcon_api:api_host:'%env(APP_API_HOST)%'json_schema_dir:'%kernel.project_dir%/src/Json/Schema/'jwt:enabled:true# set false to disable JWT authredis_client_jwt_black_list:"@snc_redis.jwt_black_list"

Usage

Dictionary enums

For simple dictionary enums, you can use theDictionaryEnumInteface interface on Enums.It will register for serialization like a dictionary, so the result will be like:

{"id":1,"value":"Enum name"}

So, now the dictionary action will look like:

#[Route(path:'/foo/bar', name:'foo_bar', methods: [Request::METHOD_GET])]publicfunction__invoke():JsonResponse{// ...returnnewJsonResponse(data:$this->serializer->serialize(FooBar::cases()), json:true);}

In some cases, you may need to serialise dictionary value not as dictionary, for this just add in context parameterdefault_normalization with any value.

$this->serializer->serialize($fooBar,'json', ['default_normalization' =>true]);

Contributing

Read theCONTRIBUTING file.

About

📦 Base classes and helper services to build API application via Symfony.

Topics

Resources

License

Stars

Watchers

Forks

Contributors5

Languages


[8]ページ先頭

©2009-2025 Movatter.jp