samuelr / slim3-authentication
Slim3 Session-Based Authentication
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 1
Type:project
Requires
- bryanjhv/slim-session: ~3.0
- monolog/monolog: ^1.13
- slim/flash: ^0.1.0
- slim/slim: ^3.0
- slim/twig-view: ^2.0
This package is not auto-updated.
Last update: 2025-03-21 22:52:37 UTC
README
This project is a start point if you need to connect Slim3 with a secure Session-Based authentication. In this codebase you will find a complete skeleton that contains: Slim3 Framework, Twig View, MySQL Database(for users), both Bootstrap3 and FontAwesome implemented.
Why I created this project?
I had to create an application with Slim and a skeleton whitch includes a secure authentication was really helpfull: I didn't find nothing good. So I decided to create and share this simple skeleton. Hope it will help you!
Table of Content
- Getting Started
- Run Project
- What is included
- Authors
- Mind Mapping
- Documentation
- Contributing
- Licenses
Getting Started
Prerequisites
You have to install Composer before running the installation command. Click here to see more information about Composer!
Installing
Navigate into your folder and issuing this command into a command line
`$ composer create-project --no-interaction samuelr/slim3-auth myapp-name`
Run Project
$ cd myapp-name
$ sudo php -S 0.0.0.0:8888 -t public public/index.php
- Browse to http://localhost:8888
If you have any problem make sure that you launched this command with sudo!
What is included
In this project you will find a Slim3-Based Project with:
- Secure Session-Based authentication
- Twig-View Template engine
- MySQL Integration
- Bootstrap 3 and FontAwesome already loaded
- Integrated Monolog logger
- Clean and easily editable code
Authors
- Samuel Roberto - Initial project
See also the list of contributors who participated in this project.
Mind Mapping
You can find a full mind mapping for this project here:
Documentation
Create and import database
To create database table open your MySQL (or MariaDB) console and launch the queries that you find in 'myapp-name/db/slim3_auth_example.sql'. However these are the schemas:
-- MySQL Script generated by MySQL Workbench -- ven 30 giu 2017 20:20:04 CEST -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Schema slim3_auth -- ----------------------------------------------------- DROP SCHEMA IF EXISTS `slim3_auth` ; -- ----------------------------------------------------- -- Schema slim3_auth -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `slim3_auth` DEFAULT CHARACTER SET utf8 ; USE `slim3_auth` ; -- ----------------------------------------------------- -- Table `slim3_auth`.`user` -- ----------------------------------------------------- DROP TABLE IF EXISTS `slim3_auth`.`user` ; CREATE TABLE IF NOT EXISTS `slim3_auth`.`user` ( `id_user` INT NOT NULL AUTO_INCREMENT, `email` VARCHAR(120) NOT NULL, `password` VARCHAR(40) NOT NULL, `session` TEXT NOT NULL, `disabled` TINYINT(1) NOT NULL DEFAULT '0', `created_date` DATETIME NOT NULL DEFAULT NOW(), `modification_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id_user`), UNIQUE INDEX `email_UNIQUE` (`email` ASC)) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Database settings
Now open the folder 'myapp-name/app/src/config.php'. You will find the following code:
DEFINE('DB_HOST', 'localhost'); DEFINE('DB_USER', 'root'); DEFINE('DB_PASS', ''); DEFINE('DB_NAME', 'slim3_auth');
Now you can set your Database's host, user, password and name.
Key directories
app
: Application codeapp/src
: All class files within theApp
namespaceapp/templates
: Twig template filescache/twig
: Twig's Autocreated cache filesdb
: Database Fileslog
: Log filespublic
: Webserver rootvendor
: Composer dependencies
You can see a full structure at the following link.
Contributing
See the list of contributors who participated in this project.
Licenses
Slim3-Session-Base-Authentication
: Code released under MIT LicenseSlim3-Skeleton
: Added into LICENSE file