zsfoto / jeffadmin5
CakePHP 的 JeffAdmin5 插件
1.1.2
2024-09-19 11:49 UTC
Requires
- php: >=8.1
- cakephp/cakephp: ^5.0.0
Requires (Dev)
- phpunit/phpunit: ^10.1
- dev-main
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
This package is not auto-updated.
Last update: 2024-10-03 12:04:58 UTC
README
最新版本:1.0.26
安装
您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。
##带翻译
CREATE TABLE `i18n` ( `id` int(11) NOT NULL, `locale` varchar(6) NOT NULL, `model` varchar(255) NOT NULL, `foreign_key` int(10) NOT NULL, `field` varchar(255) NOT NULL, `content` text DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; CREATE TABLE `langs` ( `id` int(11) NOT NULL, `pos` int(11) NOT NULL, `name` varchar(100) NOT NULL, `lang` varchar(6) NOT NULL, `visible` tinyint(1) UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Languages table'; INSERT INTO `langs` (`id`, `pos`, `name`, `lang`, `visible`) VALUES (1, 1, 'Magyar', 'hu', 1), (2, 500, 'Angol GB', 'en_GB', 1), (3, 500, 'Italian', 'it', 0), (4, 500, 'Deutsch', 'de', 1), (5, 600, 'Croatian', 'hr', 1); ALTER TABLE `i18n` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `I18N_LOCALE_FIELD` (`locale`,`model`,`foreign_key`,`field`), ADD KEY `I18N_FIELD` (`model`,`foreign_key`,`field`); ALTER TABLE `langs` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `lang` (`lang`), ADD UNIQUE KEY `Unique_Languages` (`name`,`lang`), ADD KEY `pos` (`pos`); ALTER TABLE `i18n` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1; ALTER TABLE `langs` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
安装 composer 包的推荐方式是
安装 CakePHP 5
# composer create-project --prefer-dist cakephp/app:~5.0 my_app_name
添加 JeffAdmin5 插件
# composer require zsfoto/jeffadmin5
###编辑以下文件
src/Application.php
public function bootstrap(): void { ... //Configure::write('DebugKit.forceEnable', true); Configure::write('DebugKit.forceEnable', function() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip === '127.0.0.1'; //return false; }); //$this->addPlugin(\CakeDC\Users\Plugin::class); //Configure::write('Users.config', ['users']); // Load more plugins here $this->addPlugin('JeffAdmin5'); ... }
在 src/view/AppView.php 中
/* ############################ Don't use yet ######################### public function initialize(): void { parent::initialize(); ... $this->loadHelper('JeffAdmin5.Form'); ... } */
将以下路径添加到 config/routes.php 中的 admin 路径
$routes->prefix('Admin', function (RouteBuilder $builder) { $builder->scope('/', function (RouteBuilder $builder) { //$builder->setExtensions(['json', 'xml', 'xlsx']); $builder->connect('/', ['controller' => 'Customers', 'action' => 'index']); $builder->fallbacks(DashedRoute::class); }); });
将以下行添加到 config/bootstrap.php 文件的末尾
Configure::write('Bake.theme', 'jeffAdmin5'); Configure::write('Session', [ 'defaults' => 'php', 'cookie' => 'NameOfCookie', 'timeout' => 4320 // 3 days ]);
src/Controller/Admin/AppController.php
#cp (or copy) src/Controller/AppController.php src/Controller/Admin/AppController.php
并更新内容
namespace App\Controller\Admin; use Cake\Core\Configure; use JeffAdmin5\Controller\AppController as JeffAdmin5; class AppController extends JeffAdmin5 { }
侧菜单和操作配置:并且进行配置!
#cp (or copy) /vendor/zsfoto/jeffadmin5/config/jeffadmin5.php /config/jeffadmin5.php #cp (or copy) /vendor/zsfoto/jeffadmin5/config/sidebarmenu.php /config/sidebarmenu.php
在 bake 时不要忘记添加 admin 前缀
# cake bake model table # cake bake controller table --prefix=admin # cake bake template table --prefix=admin
创建 Setup 表
CREATE TABLE `setups` ( `id` int(10) UNSIGNED NOT NULL, `user_id` varchar(36) NOT NULL DEFAULT 'init', `name` varchar(200) NOT NULL, `slug` varchar(200) NOT NULL, `value` longtext NOT NULL, `type` varchar(10) NOT NULL DEFAULT 'string', `editable` tinyint(1) UNSIGNED NOT NULL DEFAULT 1, `created` datetime NOT NULL, `modified` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_hungarian_ci COMMENT='Setups table'; ALTER TABLE `setups` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `user_id` (`user_id`); ALTER TABLE `setups` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
####使用 Setup 值
$get_setup_value = $this->Setup->getValue( 'dev_mode', // Slug: [ 'name' => 'Teszt value of DEV mode', // Readable name: 'type' => 'bool', // Types: // int, integer, number, float, real, string, text, richtext, date, time, datetime 'value' => true, // Value 'editable' => true // Editable on admin page. Default value: true ] ); // Foe example: $setup_value = $this->Setup->getValue( 'for_eample', [ 'name' => 'For example stored value', 'type' => 'bool', 'value' => true, 'editable' => false ] );
别忘了添加 app_local.php
// This app version 'Programversion' => '1.0.0',