BaseController
Last updated
Was this helpful?
Was this helpful?
<?php
protected function render($layout, $view, $isreturn = false) {}<?php
protected function json($data = [], $statusCode = 200) {}<?php
protected function success($data = [], $message = 'Success') {}<?php
protected function error($message = 'An error occurred', $errors = [], $statusCode = 400) {}<?php
protected function get_success($data = [], $message = 'Success') {}<?php
protected function get_error($message = 'An error occurred', $errors = [], $statusCode = 400) {}<?php
namespace App\Controllers;
use System\Core\BaseController;
class HomeController extends BaseController {
public function index() {
// Set some data to be passed to the view
$this->data('title', 'Home Page');
$this->data('content', 'Welcome to PHPFast Framework!');
// Render the view
$this->render('backend', 'backend/home/index');
}
public function getData() {
// Example data
$data = [
'name' => 'PHPFast Framework',
'email' => '[email protected]'
];
// Return success response in JSON format
$this->success($data, 'Data retrieved successfully');
}
}