dev-master
9999999-devYii2 gii for chinese
Apache-2.0
The Requires
by funson86
extension yii2 blog
0.0.1
0.0.1.0Yii2 gii for chinese
Apache-2.0
The Requires
by funson86
extension yii2 blog
Yii2 gii for chinese
主要针对中文和项目的优化, (*1)
所有的表格最好以一下方式结尾, (*2)
`sort_order` int(11) NOT NULL DEFAULT '50', `status` int(11) NOT NULL DEFAULT '1', `created_at` int(11) NOT NULL DEFAULT '1', `updated_at` int(11) NOT NULL DEFAULT '1', `created_by` int(11) NOT NULL DEFAULT '1', `updated_by` int(11) NOT NULL DEFAULT '1',
一个常用的表:, (*3)
CREATE TABLE `prefix_test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `parent_id` int(11) NOT NULL DEFAULT '0', `product_id` int(11) NOT NULL, `name` varchar(255) NOT NULL, `content` text, `user_id` int(11) NOT NULL DEFAULT '0', `type` int(11) NOT NULL DEFAULT '1', `sort_order` int(11) NOT NULL DEFAULT '50', `status` int(11) NOT NULL DEFAULT '1', `created_at` int(11) NOT NULL DEFAULT '1', `updated_at` int(11) NOT NULL DEFAULT '1', `created_by` int(11) NOT NULL DEFAULT '1', `updated_by` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `parent_id` (`parent_id`), KEY `product_id` (`product_id`), KEY `created_at` (`created_at`), KEY `FK_test_plan_id` (`plan_id`), CONSTRAINT `FK_test_product_id` FOREIGN KEY (`product_id`) REFERENCES `prefix_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
The preferred way to install this extension is through composer., (*4)
Either run, (*5)
php composer.phar require funson86/yii2-gii "dev-master"
or add, (*6)
"funson86/yii2-gii": "dev-master"
to the require section of your composer.json
file., (*7)
Once the extension is installed, simply use it in your code by :, (*8)
在main-local.php中配置:, (*9)
if (!YII_ENV_TEST) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = 'yii\debug\Module'; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'generators' => [ //here 'crud' => [ //name generator 'class' => 'yii\gii\generators\crud\Generator', //class generator 'templates' => [ //setting for out templates 'funson86' => '@vendor/funson86/yii2-gii/crud/default', //name template => path to template ] ], 'model' => [ //name generator 'class' => 'yii\gii\generators\model\Generator', //class generator 'templates' => [ //setting for out templates 'funson86' => '@vendor/funson86/yii2-gii/model/default', //name template => path to template ] ], ], ]; }
在gii新建模板时会多出一个选项。, (*10)
如果要统一输出显示的日期时间格式,修改config/main.php, (*11)
'formatter' => [ 'dateFormat' => 'yyyy-MM-dd', 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss', 'decimalSeparator' => ',', 'thousandSeparator' => ' ', 'currencyCode' => 'EUR', ],
一些小技巧参考 tips, (*12)
Yii2 gii for chinese
Apache-2.0
extension yii2 blog
Yii2 gii for chinese
Apache-2.0
extension yii2 blog