PHP code example of moyer / qtemp

1. Go to this page and download the library: Download moyer/qtemp 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/ */

    

moyer / qtemp example snippets


(new \qtemp\btn\Button)
    ->text('提交')
    ->btnclass('btn-primary')
    ->action('/submit')
    ->fa('save')
    ->echo();

// 安全获取数组值
$value = \qtemp\getValue($item, 'user.name', '默认值');

// 通配符字符串匹配
$property = \qtemp\getSubstring('addTitle', 'add*');

// 创建一个按钮
(new \qtemp\btn\Button)->text('点击我')
       ->btnclass('btn-success')
       ->size('btn-lg')
       ->action('/api/submit')
       ->param(['id' => 1])
       ->fa('fa-check')
       ->echo(); // 输出按钮

// 文本输入框
(new \qtemp\form\TextInput)->name('username')
      ->title('用户名')
      ->value('')
      ->le('状态')
       ->option([1 => '启用', 0 => '禁用'])
       ->value(1)
       ->group()->echo();

// 多行文本框
(new \qtemp\form\Textarea)->name('description')
         ->title('描述')
         ->rows(5)
         ->group()->echo();

// 导航标签
(new \qtemp\control\NavTab)->tab([
    'index' => '列表',
    'add' => '新增'
])->echo();

// 数据表格
(new \qtemp\control\TableMin)->list($items)
    ->column([
        'ID' => 'id',
        '标题' => 'title',
        '创建时间' => 'create_time'
    ])
    ->autoAction()
    ->echo();

(new \qtemp\excel\ExcelExport)->column([
        'ID' => 'id',
        '用户名' => 'username',
        '邮箱' => 'email',
        '创建时间' => function($item) {
            return date('Y-m-d H:i:s', $item['create_time']);
        }
    ])
    ->data($userList)
    ->name('用户列表')
    ->limit(10000)
    ->export();

// 单图片上传
(new \qtemp\form\ImageUpload)->name('avatar')
    ->title('头像')
    ->group()
    ->echo();

// 多文件上传
(new \qtemp\form\FileUploadMulti)
    ->name('attachments')
    ->title('附件')
    ->group()
    ->echo();