Download the PHP package falco442/slim-token-auth-mvc without Composer
On this page you can find all versions of the php package falco442/slim-token-auth-mvc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download falco442/slim-token-auth-mvc
More information about falco442/slim-token-auth-mvc
Files in falco442/slim-token-auth-mvc
Package slim-token-auth-mvc
Short Description A Slim Framework skeleton to build REST API with token autentication
License MIT
Homepage https://github.com/falco442/slim-token-auth-mvc
Informations about the package slim-token-auth-mvc
Note: this application is under development
Slim Framework 3 with Token Authentication
use this application (derived from the slim/slim-skeleton) to develop a REST json api application with token based authentication
Install the Application
Run this command from the directory in which you want to install your new application.
composer create-project falco442/slim-token-auth-mvc [app-name]
To run the application in development, you can also run this command.
composer start
Run this command to run the test suite
composer test
Configuration
Database configuration
This application uses the Illuminate\Database\Capsule\Manager
(see api) provided with Laravel as ORM.
You can config the DB in the src/settings.php
for the connection. The connection provider is already configured in src/dependencies.php
.
CORS
In order to make the application able to accept CORS (Cross Origin Site Request), I added the Tuupola cors-middleware. It's already configured in the file src/middleware.php
.
Settings
Modify the settings.php
file to make application work:
Use
Controllers
This application is alreaady configured with a base Controller
class, to work as a little MVC. See the file src/Controller/UsersController.php
as an example.
Login
To to the login of the user, place a route in routes.php like this (I'm using UsersController
as example)
and so the action login
of the UsersController
will be invoked. Use the authenticate()
method of the class TokenAuth
, as this
Pass in the body of the request the login fields, as you set in the settings
array
and the authenticate
method will return a user array if user exists, and false
otherwise. If everything was OK, TokenAuth
will refresh token and the field token_created
All versions of slim-token-auth-mvc with dependencies
slim/slim Version ^3.1
slim/php-view Version ^2.0
monolog/monolog Version ^1.17
illuminate/database Version ~5.1
tuupola/cors-middleware Version ^0.5.2