1. Go to this page and download the library: Download alsocoder/apnaphp 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/ */
alsocoder / apnaphp example snippets
use ApnaPHP\Routing\Request;
use ApnaPHP\Routing\Response;
class UsersHandler
{
public function GET(Request $request)
{
return Response::json(['users' => User::all()]);
}
public function POST(Request $request)
{
$user = User::create($request->all());
return Response::json($user, 201);
}
}
$users = User::all();
namespace App\Models;
use ApnaPHP\Database\Model;
class User extends Model
{
protected $table = 'users';
protected $autoMigrate = true;
protected $schema = [
'name' => 'ing|in:active,inactive|default:active'
];
protected $fillable = ['name', 'email', 'phone', 'age'];
protected $hidden = ['password'];
}