1000 search results

21 lines | config/packages/api_platform.yaml
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
// ... lines 4 - 21
See Code Block in Script
22 lines | config/packages/api_platform.yaml
api_platform:
// ... lines 2 - 5
path_segment_name_generator: api_platform.path_segment_name_generator.dash
// ... lines 7 - 22
See Code Block in Script
19 lines | config/packages/api_platform.yaml
api_platform:
// ... lines 2 - 17
enable_docs: false
See Code Block in Script
20 lines | config/packages/api_platform.yaml
api_platform:
// ... lines 2 - 18
enable_entrypoint: false
See Code Block in Script
API Login Form with json_login

…vue: If you're not familiar with Vue, don't worry. We will do some light coding in it, but I'm mostly using it as an example to make some API requests. Down near the bottom, on submit, we make a POST request to …

5:36
API Token Scopes

…>markAsTokenAuthenticated() and pass $token->getScopes(): Done! Let's take it for a test drive! Back over on Swagger, it already has our API token... so we can just re-execute the request. Cool: we see the Authorization header. Did it authenticate with the correct scopes…

5:51
API Auth 101: Session? Cookies? Tokens?

…site, a single page application built in Hipster.js or even in a mobile app. In all those situations, the user of your API will be sending an email & password. By the way, if you do not have this situation, that doesn't change much…

4:05
API-Style Uploads

…you can't put binary data in JSON: it's just not supported. API's work around this fact by expecting the client to base64 encode the data. Search for "base64 encode online" to find a site that can base64 encode some stuff for us…

9:51
API Endpoint & Errors with Dropzone

…t break anything technically... but it's weird. Our endpoint isn't setup to be an API endpoint - it's 100% traditional: we're redirecting on error and success. But now that we are using this as an API endpoint, let's fix that! And..…

4:53
API Pagination Done Easily

…These are Internet-wide standards like self. So if you use these names for your links, your API will be consistent with a lot of other APIs. The other important thing to notice in this example is that pagination is done with query parameters. Technically…

8:48
API Auth & State via AJAX

…second request below for /login. Let's back up. First, for some reason, authentication is failing for the API request. We'll get to that in a minute. Second, fetch() requests will normally show up under the XHR network filter. We'll see that later…

7:33
API Token Authenticator

…possesses" this token - can use it to authenticate, without needing to provide any other types of authentication, like a master key or a password. Most API tokens, also known as "access tokens" are "bearer" tokens. And this is a standard way of attaching them to…

7:01
API Auth: Do you Need it? And its Parts

…instantly make authenticated AJAX requests from JavaScript, because those requests send the session cookie. So, if the only thing that needs to use your API is your own JavaScript, just use LoginFormAuthenticator. Oh, and if you need to be fancier with your login form, sure…

7:56
API Token Authenticator Part 2!

When the request sends us a valid API token, our authenticator code is working! At least all the way to checkCredentials(). But before we finish that, I want to see what happens if a client sends us a bad key. So let's see... the…

8:18
// ... lines 1 - 10
use Symfony\Bundle\SecurityBundle\Security;
class DragonTreasureIsPublishedExtension implements QueryCollectionExtensionInterface, QueryItemExtensionInterface
{
public function __construct(private Security $security)
{
}
// ... lines 18 - 50
}
See Code Block in Script
// ... lines 1 - 12
class DragonTreasureIsPublishedExtension implements QueryCollectionExtensionInterface, QueryItemExtensionInterface
{
// ... lines 15 - 33
private function addIsPublishedWhere(string $resourceClass, QueryBuilder $queryBuilder): void
{
if (DragonTreasure::class !== $resourceClass) {
return;
}
$rootAlias = $queryBuilder->getRootAliases()[0];
$user = $this->security->getUser();
if ($user) {
$queryBuilder->andWhere(sprintf('%s.isPublished = :isPublished OR %s.owner = :owner', $rootAlias, $rootAlias))
->setParameter('owner', $user);
} else {
$queryBuilder->andWhere(sprintf('%s.isPublished = :isPublished', $rootAlias));
}
$queryBuilder->setParameter('isPublished', true);
}
}
See Code Block in Script
// ... lines 1 - 2
namespace App\ApiPlatform;
use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Metadata\Operation;
use Doctrine\ORM\QueryBuilder;
class DragonTreasureIsPublishedExtension implements QueryCollectionExtensionInterface
{
public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, Operation $operation = null, array $context = []): void
{
// TODO: Implement applyToCollection() method.
}
}
See Code Block in Script