Yii2 Lesson - 05 Gii Module CRUD Application
建立Gii的 CRUD
先查看是否开发环境,增加自己的IP地址
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1','110.82.170.196'],
];
其次数据库建立个新表
/*show CREATE table posts */
CREATE TABLE `posts` (
`post_id` int(11) NOT NULL AUTO_INCREMENT,
`post_title` varchar(100) NOT NULL,
`post_description` text NOT NULL,
`author_id` int(11) NOT NULL,
PRIMARY KEY (`post_id`),
KEY `author_id` (`author_id`),
CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`author_id`) REFERENCES `users` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
然后在 ?r=gii中建立models/post.php 和 CURD
解决Warning: scandir() has been disabled for security reasons in…的问题
删除 vim /usr/local/php/etc/php.ini 里面的函数 scandir()
重启系统(写多点 用得到的是php-fpm)
/usr/local/nginx/sbin/nginx -s reload
service php-fpm restart
service network restart