Table of Contents
Yii2的相关学习记录,后台模板和gii(三),yii2gii
Home php教程 php手册 Yii2的相关学习记录,后台模板和gii(三),yii2gii

Yii2的相关学习记录,后台模板和gii(三),yii2gii

Jun 13, 2016 am 08:43 AM
gii yii2 three Backstage and study template of Related Record

Yii2的相关学习记录,后台模板和gii(三),yii2gii

前面已经可以正常登录,但我们需要体验下最常用的增删查改的操作。这里就需要gii,通过gii可以方便的生成表单、表格的框架,不需要我们再写重复的东西。

gii访问地址:http://localhost/vishun/frontend/web/index.php?r=gii或者http://localhost/vishun/backend/web/index.php?r=gii,由于前后台文件都有配置,所以都可以访问。由于Yii框架高级版已经在common/models中存在user模型了,所以,我们直接用GRUD来生成user表的后台控制器和增删查改的表单。这没什么好说的,由于是高级版本,所以将提示中的app(基础版是app)改成你想要生成的目录(backend、frontend、common),如下图:

生成后就可以访问查看了:http://localhost/vishun/backend/web/index.php?r=user,如下图:

还是蛮不错的,可以点击看看,比Yii1的界面要好多了。但是单单这种界面,当我有多个表的展示时,是满足不了我们的要求的。所以应该有一个比较好的后台展示模板才行,网上搜了下,挺多人推荐AdminLTE模板,界面也不错,和阿里云的后台有点像,就打算用它了。

这时候我们又会用到原先提到的packagist,在其中搜索“yii2-adminlte”,会看到很多人已经将这个模板与Yii2集成在一起了,这里我们选择下载量最多的“dmstr/yii2-adminlte-asset”来作为我们的模板。一切按照操作说明来即可,需要注意的地方:

1、由于composer默认会下到vendor中,而一些菜单添加配置等文件同样需要我们自己在vendor目录中配置,这显然是不合适的,因为vendor目录在团队合作中是不提交的(vendor文件太大,而且团队成员通过composer.json,可轻松下载更新vendor文件)。所以必须按照说明将文件copy出来。方法一,可以作为一个主题,在backend/config/main.php的配置文件中:如下

'view' =><span>[
    </span>'theme' =><span>[
        </span>'pathMap' => ['@app/views'=>'@backend/themes/default'],<span>//</span><span>在backend中新建themes/default文件文件</span>
        'baseUrl' => '@web/themes/default',<span>
    ]</span>,<span>
]</span>,
Copy after login

方法二:直接覆盖backend/views中的文件,当然上方的配置文件也不需要写了,去掉就行。

2、更改颜色主题时,文档说的不是很明白,除了配置文件外,还需要更改你拷贝文件中的layouts/main.php中下面这行:

 <body <span>class</span>="hold-transition skin-purple sidebar-mini">
Copy after login

改成和配置文件css名一致就可以更改主题颜色了。

现在即便增加其它表的展示,只需要在拷贝文件中的layouts/left.php的menu小部件中增加,就会在左边显示出来,而且整体也比原先好看多了:

这里还有两个延伸要说,一个是如何自定义gii模板,一个是如何引用AdminLTE中的其它扩展css、js等,不过太晚了,先睡觉了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Discuz background login problem solution revealed Discuz background login problem solution revealed Mar 03, 2024 am 08:57 AM

The solution to the Discuz background login problem is revealed. Specific code examples are needed. With the rapid development of the Internet, website construction has become more and more common, and Discuz, as a commonly used forum website building system, has been favored by many webmasters. However, precisely because of its powerful functions, sometimes we encounter some problems when using Discuz, such as background login problems. Today, we will reveal the solution to the Discuz background login problem and provide specific code examples. We hope to help those in need.

Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Mar 12, 2024 pm 07:20 PM

Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

Are you worried about WordPress backend garbled code? Try these solutions Are you worried about WordPress backend garbled code? Try these solutions Mar 05, 2024 pm 09:27 PM

Are you worried about WordPress backend garbled code? Try these solutions, specific code examples are required. With the widespread application of WordPress in website construction, many users may encounter the problem of garbled code in the WordPress backend. This kind of problem will cause the background management interface to display garbled characters, causing great trouble to users. This article will introduce some common solutions to help users solve the trouble of garbled characters in the WordPress backend. Modify the wp-config.php file and open wp-config.

Revealing the appeal of C language: Uncovering the potential of programmers Revealing the appeal of C language: Uncovering the potential of programmers Feb 24, 2024 pm 11:21 PM

The Charm of Learning C Language: Unlocking the Potential of Programmers With the continuous development of technology, computer programming has become a field that has attracted much attention. Among many programming languages, C language has always been loved by programmers. Its simplicity, efficiency and wide application make learning C language the first step for many people to enter the field of programming. This article will discuss the charm of learning C language and how to unlock the potential of programmers by learning C language. First of all, the charm of learning C language lies in its simplicity. Compared with other programming languages, C language

Let's learn how to input the root number in Word together Let's learn how to input the root number in Word together Mar 19, 2024 pm 08:52 PM

When editing text content in Word, you sometimes need to enter formula symbols. Some guys don’t know how to input the root number in Word, so Xiaomian asked me to share with my friends a tutorial on how to input the root number in Word. Hope it helps my friends. First, open the Word software on your computer, then open the file you want to edit, and move the cursor to the location where you need to insert the root sign, refer to the picture example below. 2. Select [Insert], and then select [Formula] in the symbol. As shown in the red circle in the picture below: 3. Then select [Insert New Formula] below. As shown in the red circle in the picture below: 4. Select [Radical Formula], and then select the appropriate root sign. As shown in the red circle in the picture below:

Discuz background account login exception, how to deal with it? Discuz background account login exception, how to deal with it? Mar 09, 2024 pm 05:51 PM

Title: Discuz background account login exception, how to deal with it? When you use the backend management of the Discuz forum system, you may sometimes encounter abnormal account login. This could be due to a variety of reasons, including a wrong password, account being blocked, network connection issues, etc. When encountering this situation, we need to solve the problem through simple troubleshooting and processing. Check whether the account number and password are correct: First, confirm whether the account number and password you entered are correct. When logging in, make sure the capitalization is correct and the password is

How to add PPT mask How to add PPT mask Mar 20, 2024 pm 12:28 PM

Regarding PPT masking, many people must be unfamiliar with it. Most people do not understand it thoroughly when making PPT, but just make it up to make what they like. Therefore, many people do not know what PPT masking means, nor do they understand it. I know what this mask does, and I don’t even know that it can make the picture less monotonous. Friends who want to learn, come and learn, and add some PPT masks to your PPT pictures. Make it less monotonous. So, how to add a PPT mask? Please read below. 1. First we open PPT, select a blank picture, then right-click [Set Background Format] and select a solid color. 2. Click [Insert], word art, enter the word 3. Click [Insert], click [Shape]

Learn the main function in Go language from scratch Learn the main function in Go language from scratch Mar 27, 2024 pm 05:03 PM

Title: Learn the main function in Go language from scratch. As a simple and efficient programming language, Go language is favored by developers. In the Go language, the main function is an entry function, and every Go program must contain the main function as the entry point of the program. This article will introduce how to learn the main function in Go language from scratch and provide specific code examples. 1. First, we need to install the Go language development environment. You can go to the official website (https://golang.org

See all articles