PHP code example of zxf / xfadmin

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

    

zxf / xfadmin example snippets


echo XfAdmin::page([
    'title'   => '仪表盘',
    'content' => XfAdmin::card(['title' => '欢迎', 'body' => 'Hello XfAdmin']),
]);

use zxf\XfAdmin\XfAdmin;

public function index()
{
    return response(XfAdmin::page([
        'title'   => '仪表盘',
        'layout'  => 'vertical',
        'content' => XfAdmin::card(['title' => '欢迎', 'body' => 'Hello XfAdmin']),
    ]));
}

return [
    \zxf\XfAdmin\ThinkPHP\Service::class,
];

$card = XfAdmin::card(['title' => '标题', 'body' => '内容']);
echo $card;                 // 渲染
$html = (string) $card;    // 取字符串
$card->render();            // 显式渲染

echo XfAdmin::card([
    'title' => '用户列表',
    'body'  => XfAdmin::dataTable([
        'columns' => ['ID', '姓名', '邮箱'],
        'data'    => $users,
    ]),
]);

['text' => '菜单', 'icon' => 'ti ti-x', 'url' => '/x', 'badge' => ['text' => '9', 'class' => 'bg-danger'], 'children' => [...]]

echo XfAdmin::assets()->head();     // 放入 <head>
// ... 你的内容 ...
echo XfAdmin::assets()->scripts();  // 放在 </body> 前

XfAdmin::has('dataTable');          // 是否已注册
XfAdmin::version();                 // '1.0.2'
XfAdmin::asset('css/xfadmin.css');  // /zxf/xfadmin/css/xfadmin.css?v=1.0.2
bash
php artisan vendor:publish --tag=xfadmin-assets   # 发布到 public/zxf/xfadmin
php artisan vendor:publish --tag=xfadmin-config   # 发布配置(可选)
bash
php think xfadmin:publish
bash
php -S 127.0.0.1:8900 demo/index.php     # 直接运行
# 或:php -S 127.0.0.1:8900 demo/router.php