I am using the API platform as a basis for my API, which has been great, and it exposes the entities I created with all the different method types. However, when I try to create the custom pages with functions via the API url, it doesn’t seem to work.
My security.yaml
file:
security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
SymfonyComponentSecurityCoreUserPasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: AppEntityUser
property: id
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: app_user_provider
json_login:
check_path: api_login
access_token:
token_handler: AppSecurityApiTokenHandler
My SecurityController.php
:
<?php
namespace AppController;
use SymfonyComponentNotifierNotifierInterface;
use SymfonyComponentNotifierMessageSmsMessage;
use SymfonyComponentNotifierRecipientRecipient;
use SymfonyComponentNotifierBridgeTwilioTwilioOptions;
use SymfonyBundleFrameworkBundleControllerAbstractController;
class SecurityController extends AbstractController
{
#[Route('/api/login', name: 'api_login', methods: ['POST'])]
public function loginRequest(NotifierInterface $notifier, Request $request, TexterInterface $texter): Response
{
$phoneNumber = $request->getPayload()->get('phoneNumber');
}
}
When I send a post method with a fetch call in the network tab of my browser, I get the following error:
So why is it returning a 404 when the route was created in a controller? First time doing all of this as just a pure API and I’m confused by the structure of these pages/items.