PHP Framework YII的里的gii设置。
这些步骤是转贴的。我按照这些步骤完成设置。最后几行是我自己的心得。 一、设置YII的GII。 自动生成代码从版本1.1.2开始,Yii 装备了一个基于 web 的代码生成工具,叫做 Gii。它替代之前的 yiic shell 生成工具(它运行在命令行)。在这一小节中,我们将描述
这些步骤是转贴的。我按照这些步骤完成设置。最后几行是我自己的心得。
一、设置YII的GII。
自动生成代码从版本1.1.2开始,Yii 装备了一个基于 web 的代码生成工具,叫做 Gii。它替代之前的 yiic shell 生成工具(它运行在命令行)。在这一小节中,我们将描述如何使用 Gii 以及如何扩展 Gii 来增加我们的开发生产力。使用Gii
Gii 以一个模块的方式运行,必须在一个已存在的Yii应用内部使用。要使用 Gii,我们首先改变应用配置如下:
return array (
|
......
|
'modules' => array (
|
'gii' => array (
|
'class' => 'system.gii.GiiModule' ,
|
'password' => 'pick up a password here' ,
|
// 'ipFilters'=>array(...a list of IPs...),
|
// 'newFileMode'=>0666,
|
// 'newDirMode'=>0777,
|
),
|
),
|
); |
在上面,我们声明了一个模块名为 gii,它的类是GiiModule。我们也为这个模块指定了一个密码,当访问 Gii 时需要输入。
默认的,处于安全考虑,Gii 被配置为只允许在本地访问。若我们想要在另外信任的机器上访问,可以在如上代码中配置 GiiModule::ipFilters 属性。
因为Gii可以产生并保存新代码文件到已存在的应用中,我们需要确保 web 服务器进程有权限这样做。在上面的 GiiModule::newFileMode 和 GiiModule::newDirMode 属性控制这些新文件和目录应当如何被产生。
注意:Gii 主要是一个开发工具。因此,它应只被安装于一个开发机器上。因为它可以产生新PHP脚本文件到应用中,我们应当注意采取安全措施(例如 password,IP filters)。
现在我们可以通过 URL http://hostname/path/to/index.php?r=gii 访问 Gii ,这里我们假设 http://hostname/path/to/index.php 是访问已存在Yii应用的 URL。
若已存在的Yii应用使用 path 格式的 URL ,我们可以通过 URL http://hostnamepath/to/index.php/gii 访问 Gii。我们也需要增加如下 URL 规则到已存在URL规则的前面:
'components' => array (
|
......
|
'urlManager' => array (
|
'urlFormat' => 'path' ,
|
'rules' => array (
|
'gii' => 'gii' ,
|
'gii/<controller:>'</controller:> => 'gii/<controller>'</controller> ,
|
'gii/<controller:>/<action:>'</action:></controller:> => 'gii/<controller>/<action>'</action></controller> ,
|
...existing rules...
|
),
|
),
|
) |
Gii 有一个新的默认代码生成器。每个代码生成器负责生成一个特定类型的代码。例如, controller 生成器生成一个控制器类以及一些动作视图脚本;model 生成器为指定的数据表生成一个 ActiveRecord 类。
二、目录存在和权限。
我是根据这个步骤去完成的。我的yii还是不能成功。后来才发现。
- yii的工作目录有看有没有建好;
- 工作目录是否有写的权限;
- 不止一个目录要检查,要看看还有其他相关的目录是否有设置。
在做完以上3个步骤后,我的gii就成功运行。希望这个能给大家一个提示。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
