Giter VIP home page Giter VIP logo

php_mvc_login_and_register's Introduction

PHP API Project

This project is a simple PHP API for user registration and login. It is structured using an MVC pattern with a custom routing system.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/chamasab/php_mvc_login_and_register.git
    cd php_mvc_login_and_register
  2. Install Composer dependencies: Ensure you have Composer installed. Then, run:

    composer install
  3. Set up your environment:

    • Create a MySQL database for the project.
    • Update the database credentials in src/config/config.php.
  4. Run the PHP built-in server:

    php -S localhost:8000 -t public

Directory Structure

/php_mvc_login_and_register
│
├── /public
│   └── index.php
│
├── /src
│   ├── /controllers
│   │   └── UserController.php
│   ├── /models
│   │   └── UserModel.php
│   ├── /routes
│   │   └── web.php
│   ├── /core
│   │   ├── Router.php
│   │   ├── Controller.php
│   │   ├── Model.php
│   │   └── View.php
│   ├── /middlewares
│   │   └── AuthMiddleware.php
│   ├── /helpers
│   │   └── ResponseHelper.php
│   └── /config
│       └── config.php
│
├── /logs
│   └── app.log
│
└── composer.json

Configuration

Update the database configuration in src/config/config.php:

<?php

return [
    'db' => [
        'host' => 'localhost',
        'dbname' => 'your_database',
        'user' => 'your_username',
        'pass' => 'your_password'
    ],
    'log_file' => __DIR__ . '/../../logs/app.log'
];
?>

API Endpoints

  • Register

    • URL: /register
    • Method: POST
    • Body: JSON
    {
        "name": "John Doe",
        "email": "[email protected]",
        "password": "securepassword"
    }
    
    • Response
      {
          "message": "User registered successfully"
      }
    
  • Login

    • URL: /login

    • Method: POST

    • Body: JSON

    • Request

        {
          "email": "[email protected]",
          "password": "securepassword"
        }
      
    • Response

        {
          "message": "Login successful",
          "user": {
            "id": 1,
            "name": "John Doe",
            "email": "[email protected]",
            "logged_at": "2024-07-18 12:34:56"
          }
        }
      

php_mvc_login_and_register's People

Contributors

chamarasab avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.