zsfoto / jeffadmin5
JeffAdmin5 plugin for CakePHP
Installs: 92
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Language:JavaScript
Type:cakephp-plugin
Requires
- php: >=8.1
- cakephp/cakephp: ^5.0.0
Requires (Dev)
- phpunit/phpunit: ^10.1
- dev-main
- 1.1.4
- 1.1.3
- 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: 2025-06-23 10:49:20 UTC
README
Latest version: 1.0.26
Installation
You can install this plugin into your CakePHP application using composer.
##With Translate
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;
The recommended way to install composer packages is:
Install CakePHP 5:
# composer create-project --prefer-dist cakephp/app:~5.0 my_app_name
Add plugin JeffAdmin5:
# composer require zsfoto/jeffadmin5
###Edit the next files:
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'); ... }
In src/view/AppView.php:
/* ############################ Don't use yet ######################### public function initialize(): void { parent::initialize(); ... $this->loadHelper('JeffAdmin5.Form'); ... } */
Add to admin path in config/routes.php:
$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); }); });
Add this line to end of the config/bootstrap.php file:
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
and update content:
namespace App\Controller\Admin; use Cake\Core\Configure; use JeffAdmin5\Controller\AppController as JeffAdmin5; class AppController extends JeffAdmin5 { }
Configuration of side menu and operations: And configure it!
#cp (or copy) /vendor/zsfoto/jeffadmin5/config/jeffadmin5.php /config/jeffadmin5.php #cp (or copy) /vendor/zsfoto/jeffadmin5/config/sidebarmenu.php /config/sidebarmenu.php
In bake dont forget the admin prefix:
# cake bake model table # cake bake controller table --prefix=admin # cake bake template table --prefix=admin
Create Setups table
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;
####Use Setup value
$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 ] );
Don't forget to add the app_local.php:
// This app version 'Programversion' => '1.0.0',