1. Go to this page and download the library: Download mardira/mardira-framework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mardira / mardira-framework example snippets
namespace App\Controllers;
use App\Core\Controller;
class HomeController extends Controller
{
public function index()
{
$this->response(200,[
'message' => 'Hello World'
]);
}
}
use App\Core\Route;
use App\Controllers\HomeController;
Route::get('/home', [HomeController::class, 'index']);
namespace App\Models;
use App\Core\Model;
class User extends Model
{
protected $table = 'users';
protected $primaryKey = 'id';
}
namespace App\Controllers;
use App\Core\Controller;
use App\Models\User;
class HomeController extends Controller
{
public function index()
{
$user = User::all();
$this->response(200,[
'message' => 'Hello World',
'data' => $user
]);
}
}
namespace App\Database\Migrations;
use App\Core\Migration;
return new class extends Migration
{
public function up()
{
$this->schema->create('users', function ($table) {
$table->increment('id');
$table->string('name', 50);
$table->string('email',50)->unique();
$table->string('password', 64);
$table->timestamps();
});
}
public function down()
{
$this->schema->dropIfExists('users');
}
}
namespace App\Middleware;
use App\Core\Middleware;
use App\Core\Auth;
class AuthMiddleware extends Middleware
{
public function handle()
{
if (Auth::check()) {
return $next();
}
return $this->response(401, ['message' => 'Unauthorized']);
}
}