PHP code example of mikoweb / simple-api-key-bundle
1. Go to this page and download the library: Download mikoweb/simple-api-key-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mikoweb / simple-api-key-bundle example snippets
// app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Uecode\Bundle\ApiKeyBundle\UecodeApiKeyBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Mikoweb\Bundle\SimpleApiKeyBundle\MikowebSimpleApiKeyBundle(),
);
// ...
}
}
yml
security:
role_hierarchy:
ROLE_API_USER: ROLE_USER
providers:
api_key:
id: mikoweb.simple_api_key.api_key_user_provider
firewalls:
api:
pattern: ^/api/*
api_key: true
stateless: true
provider: api_key
access_control:
- { path: ^/api/, role: ROLE_API_USER }