1. Go to this page and download the library: Download dasunnethsara/zenithphp 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/ */
dasunnethsara / zenithphp example snippets
use ZenithPHP\Core\Http\Router;
Router::get('/hello', 'WelcomeController', 'index');
use ZenithPHP\Core\Controller\Controller;
class WelcomeController extends Controller
{
public function index()
{
$this->view('welcome');
}
}
use ZenithPHP\Core\Http\Router;
Router::get('/api/users', 'UserController', 'index');
use ZenithPHP\Core\Model\Model;
class User extends Model
{
protected string $table_name = 'users';
}
use ZenithPHP\Core\Controller\Controller;
use ZenithPHP\Core\Http\Response;
use ZenithPHP\Core\Http\Request;
use ZenithPHP\App\Models\User;
class UserController extends Controller
{
public function index(Request $request, Response $response)
{
$user = new User($this->pdo);
$allUsers = $user->getAll();
$response->json(['status' => 'success', 'data' => $allUsers]);
}
}