mochrira/selvi-framework

Super fast PHP Framework for building API

2.2.0 2024-10-19 07:43 UTC

README

⚡ Super fast PHP Framework for building API

Quick Start

  1. Get this framework via composer on your project directory (inside www folder if you are using Apache)
$ composer require mochrira/selvi-framework
  1. Create app/Controllers folder inside your project directory
  2. Create file HomeController.php inside app/Controllers with this content
<?php 

namespace App\Controllers;
use Selvi\Controller;

class HomeController extends Controller {

    function __construct() {
        parent::__construct();
    }

    function index() {
        return response('Welcome to Selvi Framework');
    }

}

  1. Create index.php
<?php 
require('vendor/autoload.php');

use Selvi\Route;
Route::get('/', 'HomeController@index');

Selvi\Framework::run();
  1. Create .htaccess file
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
  1. Edit your composer.json
{
    ...
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    }
    ...
}
  1. Run composer update to update your composer autoload
  2. Done. Open http://localhost/your-project on your browser to test it