All Projects → HavenShen → Slim Born

HavenShen / Slim Born

Licence: mit
Slim Framework 3 and 4 skeleton application has authentication MVC construction.

Projects that are alternatives of or similar to Slim Born

Laconia
🏺 ‎ A minimalist MVC framework.
Stars: ✭ 307 (+71.51%)
Mutual labels:  authentication, mvc
Famework
Famework is a simple to use PHP Framwork to easily create splendid but lightweight web applications.
Stars: ✭ 8 (-95.53%)
Mutual labels:  mvc-framework, mvc
Koseven
Koseven a Kohana fork compatible with PHP7
Stars: ✭ 332 (+85.47%)
Mutual labels:  mvc-framework, mvc
laminas-mvc
Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins
Stars: ✭ 90 (-49.72%)
Mutual labels:  mvc, mvc-framework
Slim3
Slim Framework 3 Skeleton Application
Stars: ✭ 70 (-60.89%)
Mutual labels:  skeleton, slim
blockbase
Lightweight MVC Framework for Node.js
Stars: ✭ 32 (-82.12%)
Mutual labels:  mvc, mvc-framework
Actframework
An easy to use Java MVC server stack
Stars: ✭ 690 (+285.47%)
Mutual labels:  mvc-framework, mvc
slim-swoole
Slim 3 MVC Skeleton With Swoole
Stars: ✭ 52 (-70.95%)
Mutual labels:  mvc, slim
Cakephp
CakePHP: The Rapid Development Framework for PHP - Official Repository
Stars: ✭ 8,453 (+4622.35%)
Mutual labels:  mvc-framework, mvc
Authorize Slim 4
Slim 4 Authorization Tutorial
Stars: ✭ 39 (-78.21%)
Mutual labels:  authentication, slim
Bingo-Framework
MVC framework for PHP
Stars: ✭ 15 (-91.62%)
Mutual labels:  mvc, mvc-framework
Dry View
Complete, standalone view rendering system that gives you everything you need to write well-factored view code.
Stars: ✭ 124 (-30.73%)
Mutual labels:  mvc, slim
leafMVC
MVC "Framework" created from Leaf PHP Framework
Stars: ✭ 25 (-86.03%)
Mutual labels:  mvc, mvc-framework
miniPHP
A small, simple PHP MVC framework skeleton that encapsulates a lot of features surrounded with powerful security layers.
Stars: ✭ 147 (-17.88%)
Mutual labels:  mvc, mvc-framework
W
Framework pédagogique de la WebForce3
Stars: ✭ 10 (-94.41%)
Mutual labels:  mvc, mvc-framework
Saturn
Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
Stars: ✭ 540 (+201.68%)
Mutual labels:  mvc-framework, mvc
aquiver
🚀 The aquifer is a java web framework based on Java8 and netty
Stars: ✭ 38 (-78.77%)
Mutual labels:  mvc, mvc-framework
SlimREST
An app skeleton for building a REST API with the Slim PHP Micro-Framework
Stars: ✭ 22 (-87.71%)
Mutual labels:  skeleton, slim
Jetweet
Jetweet is a mini twitter clone with basic functionalities, Made using ASP.NET CORE and Entity framework technologies
Stars: ✭ 29 (-83.8%)
Mutual labels:  authentication, mvc
Aspnetcorewindowsauth
Local and Windows Authentication, ASP.NET Core MVC, IdentityServer4
Stars: ✭ 87 (-51.4%)
Mutual labels:  authentication, mvc

slim-born

Scrutinizer Code Quality Build Status Code Coverage Build Status Latest Stable Version Latest Unstable Version Latest Stable Version Total Downloads License FOSSA Status

Slim Framework 3 or 4 skeleton application has authentication MVC construction.

The user authentication has been achieved, there is a need to install and use.

Installation

For Slim 3

composer create-project "havenshen/slim-born v1.0.6" [my-app]

For Slim 4

composer create-project "havenshen/slim-born 2.0" [my-app]

.env

Copy file .env.example to .env

DB_DRIVER=mysql
DB_HOST=localhost
DB_DATABASE=slimborn
DB_USERNAME=root
DB_PASSWORD=
DB_PORT=3306

Router

This is a Slim Framework Router. Reference - Slim Router

<?php

$app->get('/', 'HomeController:index')->setName('home');

$app->group('', function () {
	$this->get('/auth/signup', 'AuthController:getSignUp')->setName('auth.signup');
	$this->post('/auth/signup', 'AuthController:postSignUp');

	$this->get('/auth/signin', 'AuthController:getSignIn')->setName('auth.signin');
	$this->post('/auth/signin', 'AuthController:postSignIn');
})->add(new GuestMiddleware($container));

Controller

Use Slim Framework Twig View. Reference - Twig-View

<?php

namespace App\Controllers;

class HomeController extends Controller
{
	public function index($request, $response)
	{
		return $this->view->render($response, 'home.twig');
	}
}

Model

Use Laravel PHP Framework Eloquent. Reference - illuminate/database

<?php

namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
	protected $table = 'users';

	protected $fillable = [
		'email',
		'name',
		'password',
	];

	public function setPassword($password)
	{
		$this->update([
			'password' => password_hash($password, PASSWORD_DEFAULT)
		]);
	}
}

Middleware

<?php

namespace App\Middleware;

class AuthMiddleware extends Middleware
{
	public function __invoke($request, $response, $next)
	{
		if(! $this->container->auth->check()) {
			$this->container->flash->addMessage('error', 'Please sign in before doing that');
			return $response->withRedirect($this->container->router->pathFor('auth.signin'));
		}

		$response = $next($request, $response);

		return $response;
	}
}

Validation

Use the most awesome validation engine ever created for PHP. Reference - Respect/Validation

<?php

namespace App\Controllers\Auth;
use App\Models\User;
use App\Controllers\Controller;
use Respect\Validation\Validator as v;

class AuthController extends Controller
{
	public function postSignUp($request, $response)
	{
		$validation = $this->validator->validate($request, [
			'email' => v::noWhitespace()->notEmpty()->email()->emailAvailable(),
			'name' => v::noWhitespace()->notEmpty()->alpha(),
			'password' => v::noWhitespace()->notEmpty(),
		]);

		if ($validation->failed()) {
			return $response->withRedirect($this->router->pathFor('auth.signup'));
		}

		//	todo someting
	}
}

More basic functions

reference slim official documents - Slim Framework

Use Packages

Look Feel

slimborn look feel

Directory Structure

|-- slim-born
	|-- app
		|-- Auth
		|-- Controllers
		|-- Middleware
		|-- Models
		|-- Validation
		|-- Routes.php
	|-- bootstrap
		|-- app.php
	|-- public
	|-- resources
	....

Testing

$ phpunit

Contributing

Feel free to submit any minor enhancements, the goal here is to keep this as simple (yet as practical) as possible.

License

The MIT License (MIT). Please see License File for more information.

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].