1. Go to this page and download the library: Download vulcanphp/hyper-core 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/ */
vulcanphp / hyper-core example snippets
use hyper\database;
$database = new database([
'driver' => 'sqlite', // mysql
'file' => __DIR__ . '/../sqlite.db', // ame',
'charset' => 'utf8mb4'
]);
var_dump($database->prepare('SELECT * FROM students'));
use hyper\middleware;
$middleware = new middleware();
$middleware->add(callback);
$middleware->handle(request: $request);
use hyper\router;
$router = new router(middleware: $middleware);
$router->add('/', fn() => 'Hello World');
$response = $router->dispatch();
$response->send();
use hyper\model;
class student extends model {
protected string $table = 'students';
public string $name;
public int $age;
public string $department;
}
dump(student::get()->result());
use hyper\query;
$query = new query(database: $database, table: 'students');
dump($query->result());
use hyper\template;
$engine = new template(__DIR__);
var_dump($engine->render('welcome', ['message' => 'Welcome to App']));
use hyper\cache;
$cache = new cache('home');
var_dump($cache->load('time', fn() => 'Now :' . time(), '5 minutes'));
use hyper\utils\form;
// independent usage
$form = new form(request: $request, fields: [['type' => 'text', 'name' => 'name']]);
// usage from model
$form = new form(request: $request, model: $student);
// add new form field
$form->add(['type' => 'email', 'name' => 'email', '
use hyper\utils\image;
$image = new image(__DIR__ . '/image.png');
$image->compress(50);
$image->resize(720, 360);
$image->rotate(90);
$image->bulkResize([540 => 540, 60 => 60]);
use hyper\utils\paginator;
$paginator = new paginator(total: 500, limit: 20);
$paginator->setData([...]);
var_dump($paginator->getData(), $paginator->getLinks());
use hyper\utils\ping;
$http = new ping();
$http->download(__DIR__.'/downloads/file.jpg');
var_dump($http->get('http://domain.com/download-file'));
use hyper\utils\uploader;
$uploader = new uploader(uploadDir: __DIR__ .'/uploads', extensions: ['jpe', 'png'], multiple: true);
var_dump($uploader->upload($_FILES['upload']));
use hyper\utils\validator;
$validator = new validator(request: $request);
var_dump($validator->validate([
'name' => ['
use hyper\model;
use hyper\helpers\form;
class student extends model {
use form;
protected function form(): array {
return [
'name' => ['type' => 'text', 'form(request: $request, model: new student());
var_dump($form->render());
use hyper\helpers\mail;
$mail = new mail();
$mail->from('[email protected]', 'Shahin Moyshan');
$mail->replyTo('[email protected]');
$mail->subject('Test Mail');
$mail->body('Hello World, This is Test Mail From Shahin Moyshan');
$mail->send();
use hyper\model;
use hyper\helpers\orm;
class student extends model {
use orm;
protected function orm(): array {
return [
'department' => ['has' => 'one', 'model' => department::class],
'subjects' => ['has' => 'many-x', 'model' => subject::class, 'table' => 'students_subjects'],
'results' => ['has' => 'many', 'model' => result::class, 'formIgnore' => true],
];
}
}
var_dump(student::with(['subjects', 'results', 'department'])->paginate(20));
use hyper\model;
use hyper\helpers\uploader;
class student extends model {
use uploader;
protected function uploader(): array {
return [
[
'name' => 'photo',
'multiple' => false,
'uploadTo' => 'students',
'maxSize' => 1048576, // 1MB
'compress' => 75,
'resize' => [540 => 540],
'resizes' => [140 => 140, 60 => 60]
]
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.