MaplePHP
  • MaplePHP - Layered structure MVC PHP framework
  • Guide
    • Get started
    • Installation
    • Service Provider
    • Dependency injector
    • Controller
    • Middlewares
    • Routers
  • Navigation
    • Simple navigation
    • Dynamic navigation
  • Template engine
    • Getting started
    • Templates
      • Index
      • Views
      • Partials
    • Content (DTO)
      • String
      • Number
      • Array
      • DateTime
      • Encode
      • Dom
  • Form builder
    • Form builder
  • Database
    • MySQL
  • Service providers
    • url
    • encode
    • dir
    • DB
    • responder
  • Installations
    • Authorization & login
  • Frontend template
    • Responder
    • Views & components
    • Modals
    • Redirects
  • Access
    • MaplePHP with Docker
  • Libraries
    • Container
    • MySQL queries
    • Validation
    • Cache
    • Logger
    • Request
    • Response
  • What is?
    • Dependency injector
    • Controller
    • Middleware
    • Router
Powered by GitBook
On this page
  • 1. Install the database:
  • 2. Add organization
  • 3. Add user
  • 4. Router

Was this helpful?

  1. Installations

Authorization & login

Install the database tables with the MakePHP cli. The installation will be more streamlined in the future and the will be more functionality.

1. Install the database:

Install the bellow database tables in order.

php cli migrate create --table=organizations
php cli migrate create --table=users
php cli migrate create --table=login
php cli migrate create --table=usersToken

2. Add organization

Insert a organization into the database by executing the command bellow and follow the instructions.

php cli database insertOrg

3. Add user

Insert a user into the database by executing the command bellow and follow the instructions.

php cli database insertUser

4. Router

You can copy and paste the boilerplate code bellow to get you quickly started. The bellow boilerplate example might already exist if your project/app is newly installed.

$routes->group(function ($routes) {
    // Public login area

    // Regular page with form
    $routes->get("/{page:login}", ['Http\Controllers\Private\Login', "form"]);

    // Open form in a modal with ajax call
    $routes->get("/{page:login}/{model:model}", ['Http\Controllers\Private\Login', "formModel"]);

    // Login request
    $routes->post("/{page:login}", ['Http\Controllers\Private\Login', "login"]);

    // Forgot password
    $routes->get("/{page:login}/{type:forgot}", ['Http\Controllers\Private\Login', 'forgotPasswordForm']);
    $routes->post("/{page:login}/{type:forgot}", ['Http\Controllers\Private\Login', 'forgotPasswordPost']);

    // Change password
    $routes->get("/{page:login}/{type:reset}/{token:[^/]+}", ['Http\Controllers\Private\Login', "resetPasswordForm"]);
    $routes->post("/{page:login}/{type:reset}/{token:[^/]+}", ['Http\Controllers\Private\Login', "resetPasswordPost"]);

}, [
    [MaplePHP\Foundation\Auth\Middleware\LoggedIn::class, "publicZone"],
]);

$routes->group(function ($routes) {
    // Private area (The user is logged in)

    // Profile page
    $routes->get("/{profile:profile}", ['Http\Controllers\Private\Pages', "profile"]);

    // Logout the user
    $routes->get("/{page:logout}", ['Http\Controllers\Private\Pages', "logout"]);

}, [
    [MaplePHP\Foundation\Auth\Middleware\LoggedIn::class, "privateZone"]
]);

Now visit the "example.se/login" to login with the user you have added.

PreviousresponderNextResponder

Last updated 1 year ago

Was this helpful?