api-platform | Screencast code , script and everlasting friendship | Learning library
kandi X-RAY | api-platform Summary
kandi X-RAY | api-platform Summary
Well hi there! This repository holds the code and script for the API Platform course on SymfonyCasts.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Configures the DI container .
- Register bundles .
- Configure routes .
- Get project directory .
api-platform Key Features
api-platform Examples and Code Snippets
Community Discussions
Trending Discussions on api-platform
QUESTION
I have followed several example from symfony, api-platform and several stackoverflow examples but to no avail. I don't know if I am doing something wrong or I don't understand the concept of the voter and roles. When I tried to access the endpoint, it throws Only user with permission can view dashboard.
In services.yaml
...ANSWER
Answered 2022-Apr-04 at 15:08You're closer than you think. You don't need use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface. You can make use of Security class as follows.
QUESTION
I am learning OpenApi/Swagger API with Api-Platform. I created a new endpoint, that accepts values of an enum as a parameter:
...ANSWER
Answered 2022-Mar-25 at 08:38Enums being fairly new to PHP, they are not yet directly supported by Api-Platform.
Support will come, but for the time being you'll have to explicitly list each of the cases manually on the configuration.
While you could also store the list of 'cases' in a constant in a class (you could even do it in the enum
itself):
QUESTION
After upgrading to Api platform 2.6, the non ApiResource
entities started being serialized (ld-json) along with a fake identifier and their type. For example:
ANSWER
Answered 2022-Feb-20 at 09:54No idea how to decorate the serializer, but I will handle your issue with an event subscriber.
The "POST_SERIALIZE" priority contains the serialized response body, and you can fetch it and modify it.
Like this:
QUESTION
I am trying to create a sub resource via XML using Api Platform.
When I define the sub resource via a annotation on the entity, everything works as expected:
Entity/SocialProfile/SocialProfile.php
...ANSWER
Answered 2022-Jan-11 at 10:33The configuration for the entity holding the subresource (SocialProfile
, in this example).
QUESTION
- I have a simple symfony project base on api-platform.
- I have an entity named "MyEntity".
- I have a ressource yaml config file to tell api-platform how my entity to be query via api call .
- In the yaml, I added a route named
exportcsv
exposed asexport
, it will be called by my front with this url :http://127.0.0.1:8000/api/myentitys/export
. - This route is mapped to call the export method from MyEntity controller.
- In MyEntity controller I have a method named
export
and I will do nothing except dumping a sentence then die (dd('why?!');
).
- call the export url
- Nothing should be done on the server/database, and the front will just receive a dump of the string
why?!
- call the export url
- execute a query on the table'db named myentity
- then receive a dump of the string
why?!
I discovered the query when I added data to my table.
Performance went longer and longer as I added more data on the table.
I would never reach the Why?!
at some point.
I checked my database, and saw that a select all on the myentity table were active.
I searched a bit on the documentation, the only thing I could find is :
ANSWER
Answered 2022-Jan-06 at 18:05The query you're talking about is most likely made by the ReadListener
.
To disable it, set the read
property to false
, as explained here :
QUESTION
I created a new Symfony 5.3 project and installed API-Platform.
When I load the API Doc at /api
, I get an error :
Symfony\Component\Serializer\Exception\NotEncodableValueException : Serialization for the format "html" is not supported.
I tried to add the html
format to the api_platform.yml
config file:
ANSWER
Answered 2021-Dec-27 at 06:35Do you have twig bundle enabled
QUESTION
I am trying to implement a HTTP cache invalidation with API Platform and AWS CloudFront and as I can read in API Platform documentation:
Support for reverse proxies other than Varnish can easily be added by implementing the
ApiPlatform\Core\HttpCache\PurgerInterface
I have coded an implementation but now I can not make the built-in cache invalidation system -should be the event listener ApiPlatform\Core\Bridge\Doctrine\EventListener\PurgeHttpCacheListener
- it just keep injecting the ApiPlatform\Core\HttpCache\VarnishPurger
instead.
What I did basically, in config/services.yml
-having autowire enabled:
ANSWER
Answered 2021-Dec-23 at 14:43Alright! Found the issue. PurgeHttpCacheListener
is using a service ID so it cannot be autowired according to the Symfony docs.
From vendor/api-platform/core/src/Bridge/Symfony/Bundle/Resources/config/doctrine_orm_http_cache_purger.xml
:
QUESTION
I'm a rookie in development and it's my first time to use PHP8 attributes so I don't have a clue to guess the problem's orgin. :s
I'm trying to configure APIPlatform to determine which properties users can see associated with basic HTTP operations in my API project. For this, I'm using PHP8 attributes for ApiPlatform : #[ApiResource()] and #[Groups()].
I'm using PHP8 - Symfony 5.3 - VSCode 1.58.2 - Window 10
Problems :
It seems in the documentation that the HTTP Operations configure with normalizationContext are ok (as expected, PUT is no longer visible in my api documentation) but the properties are not affected (all the properties are still send when I'm doing a request). I assumed that serialization groups aren't working properly...
I tried to clear symfony cache with the command "php bin/console cache:clear". I received a message to tell me that I have a parse error in my #[ApiResource()] attribute but I can't find it.
Here my code :
...ANSWER
Answered 2021-Aug-12 at 11:44I manage to fix my problems... I don't know if somenone else could be interrested in the solution but just in case...
- Problem 1 : normalization groups doesn't work :
By writing
QUESTION
I use API platform with YAML instead of Annotations. It's very easy to add validation constraint on Annotation but how add constraint in YAML. In the doc in Validation chapter I don't find. https://api-platform.com/docs/core/validation/#validation
...ANSWER
Answered 2021-Nov-26 at 19:00API Platform uses the constraint validator from Symfony, you can refer to the symfony constraints documentation.
For example, using the Product sample from API platform with NotBlank constraint you should have:
QUESTION
i have a question if anybody faced this kind of issue. Ive been searching for solution but i didn't find.
Every time i generate migration with doctrine, i see in migration files:
...ANSWER
Answered 2021-Oct-28 at 14:42You probably have 1.7.0 version of ramsey/uuid-doctrine extension in your composer.lock, because it really has a bug with generating schema. Which was fixed a just few days ago: https://github.com/ramsey/uuid-doctrine/pull/165
So try downgrading to 1.6.0:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install api-platform
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page