sgmarketplace / slim-core
Core utility classes for Slim framework projects
Requires
- bshaffer/oauth2-server-php: ~1.7
- doctrine/orm: ^2.5
- fousheezy/fzy-doctrine-utils: ^1.1
- fousheezy/slim-core: 1.1.1
- slim/slim: ^2.6
Requires (Dev)
- phpunit/phpunit: 4.7.*
README
Slim core utility classes which can be re-used across microservices.
Installation
composer require sgmarketplace/slim-core
Documentation
SgSlimCore\Middleware\Json
A simple middleware that adds content-type to the response for a request that is considered an "api" request
SgSlimCore\Middleware\Auth
A simple middleware that only allows API path requests which have a valid JWT. This middleware requires a JWT service to verify logged-in status. A JWT service can be generated by using the SgSlimCore\Factory\Jwt factory.
SgSlimCore\Factory\TokenDecoder
A service factory which returns the OAuth2 library's decoder class configured with the public key (specified at
$config['sg_slim_core']['jwt']['public_key_file']
) opened in memory.
SgSlimCore\Factory\Jwt
A service factory which returns the OAuth2 library's decoded JWT (generated from the request's Authorization header)
This factory requires the following configuration to be present on the \Slim\Slim $app
level.
'sg_slim_core' => [
'token_decoder' => 'name_of_the_token_decoder_service',
'jwt' => [
'public_key_file' => 'path/to/public/key.pem',
'service_name' => 'name_of_this_service',
]
]