1. Go to this page and download the library: Download alexius-byte/rider-php 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/ */
$db->query('SELECT * FROM products WHERE price > ?', 100);
$db->query('SELECT * FROM products WHERE active = ? AND role = ?', [1, 'admin']);
$db->execute('UPDATE products SET active = 0 WHERE id = ?', [5]);
$page->data; // array — records for the current page
$page->total; // int — total records across all pages
$page->perPage; // int — records per page (capped at 1 000)
$page->currentPage; // int — current page number
$page->lastPage; // int — total number of pages
$page->from; // int — index of the first record shown (1-based), 0 when empty
$page->to; // int — index of the last record shown, 0 when empty
$page->hasNext; // bool
$page->hasPrev; // bool
class CreateUsersTable extends AbstractMigration
{
public function up(): void
{
$this->execute("
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(150) NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
");
}
public function down(): void
{
$this->execute("DROP TABLE IF EXISTS users");
}
}
class UserSeeder extends AbstractSeeder
{
public function run(): void
{
$this->insert('users', [
['name' => 'Admin', 'email' => '[email protected]'],
['name' => 'Editor', 'email' => '[email protected]'],
]);
}
}
$uploader = new UploadFiles('/var/app/storage/uploads');
$path = $uploader->upload($_FILES['photo'], AllowedType::Image);
$uploader = new UploadFiles('/var/app/storage/uploads', 10); // 10 MB
// Allow all origins
Cors::allow('*');
// Allow specific origins only
Cors::allow(['https://app.example.com', 'https://example.com']);
// With credentials (cookies / Authorization header)
Cors::allow(
origins: ['https://app.example.com'],
credentials: true
);
// Custom methods, headers, and cache duration
Cors::allow(
origins: '*',
methods: ['GET', 'POST'],
headers: ['Content-Type', 'Authorization'],
maxAge: 3600
);
$container = new Container();
// new instance on every get()
$container->bind(LoggerInterface::class, FileLogger::class);
// factory closure
$container->bind(Mailer::class, fn($c) => new Mailer($c->get(Config::class)));
// single instance for every get()
$container->singleton(Database::class, DatabaseMysql::class);
// pre-built instance
$container->instance('config', $config);