Yii2 framework study notes (1) -- environment construction
I have been learning yii2 framework recently, but learning without thinking is useless. Let’s practice by making a small baby picture display system.
The system functions are as follows:
The front desk section displays uploaded baby pictures and can accept comments/likes.
The background maintains the uploaded photos. You can choose whether the uploaded pictures are public and whether to accept comments.
You can manage comments under your own photos.
There is a task system. The task is to take a few photos of the baby every day and write a description of the number of words. You will get points for completing it.
A points system.
The front-end function is relatively simple and can be completed using jquery/bootstrap that comes with yii2.
The background plan uses adminLTE.
The environment uses the ready-made wamp server (http://www.wampserver.com/en/), and the yii framework uses composer (https://getcomposer.org/).
The advance template of yii2 is used, and the framework is built according to the official documents (https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md )
1. Switch the directory to wamp/apps in cmd and run composer.
[code]composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii2
Be careful not to run this command in the wamp/www directory, because placing it in the www directory will expose the entire yii file. In fact, only the two folders frontend/web and backend/web need to be exposed to the user
2. Switch the current directory to wamp/apps/yii2 in cmd and run the initialization command init.bat.
[code]init
in cmd (the path remains under wamp/apps/yii2). After running, it will help us create the basic table. Good
5. The yii environment built with composer has a problem that the initial path points to the wrong direction, and needs to be modified, otherwise it will not run. The file is \yii2\vendor\yiisoft\yii2\base\Application.php
public function setVendorPath($path) { $this->_vendorPath = Yii::getAlias($path); Yii::setAlias('@vendor', $this->_vendorPath); //Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower'); Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower' . DIRECTORY_SEPARATOR . 'bower-asset'); Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm'); }
The modification point is to point the path of @bower to its lower-level directory bower- in asset.
6. Create a new yii2.conf file under wamp/alias, write the following content and save it, then restart apache
Alias /babytask/admin "e:/wamp/apps/yii2/backend/web/" Alias /babytask "e:/wamp/apps/yii2/frontend/web/" <Directory "e:/wamp/apps/yii2/frontend/web/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Require all granted </Directory> <Directory "e:/wamp/apps/yii2/backend/web/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Require all granted </Directory>
Note:
Because httpd in wamp If the .conf file in alias is configured in .conf, it will be automatically included in the configuration, so as long as this file is written, it will take effect without making other connections.
The Alias in the first two lines in yii2.conf cannot be reversed. If it is written backwards, when the user enters /babytask/admin, apache will first look for things in frontend/web/admin/ instead of backend/web/, resulting in 404.
7. Open the browser, enter localhost/babytask and localhost/babytask/admin, and check whether it can be accessed normally.
The above is the Yii2 framework study notes (1) - the content of environment construction, For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

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

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

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











.NET Framework 4 is required by developers and end users to run the latest versions of applications on Windows. However, while downloading and installing .NET Framework 4, many users complained that the installer stopped midway, displaying the following error message - " .NET Framework 4 has not been installed because Download failed with error code 0x800c0006 ". If you are also experiencing it while installing .NETFramework4 on your device then you are at the right place

Whenever your Windows 11 or Windows 10 PC has an upgrade or update issue, you will usually see an error code indicating the actual reason behind the failure. However, sometimes confusion can arise when an upgrade or update fails without an error code being displayed. With handy error codes, you know exactly where the problem is so you can try to fix it. But since no error code appears, it becomes challenging to identify the issue and resolve it. This will take up a lot of your time to simply find out the reason behind the error. In this case, you can try using a dedicated tool called SetupDiag provided by Microsoft that helps you easily identify the real reason behind the error.
![SCNotification has stopped working [5 steps to fix it]](https://img.php.cn/upload/article/000/887/227/168433050522031.png?x-oss-process=image/resize,m_fill,h_207,w_330)
As a Windows user, you are likely to encounter SCNotification has stopped working error every time you start your computer. SCNotification.exe is a Microsoft system notification file that crashes every time you start your PC due to permission errors and network failures. This error is also known by its problematic event name. So you might not see this as SCNotification having stopped working, but as bug clr20r3. In this article, we will explore all the steps you need to take to fix SCNotification has stopped working so that it doesn’t bother you again. What is SCNotification.e

Microsoft Windows users who have installed Microsoft.NET version 4.5.2, 4.6, or 4.6.1 must install a newer version of the Microsoft Framework if they want Microsoft to support the framework through future product updates. According to Microsoft, all three frameworks will cease support on April 26, 2022. After the support date ends, the product will not receive "security fixes or technical support." Most home devices are kept up to date through Windows updates. These devices already have newer versions of frameworks installed, such as .NET Framework 4.8. Devices that are not updating automatically may

How to remove jquery from yii2: 1. Edit the AppAsset.php file and comment out the "yii\web\YiiAsset" value in the variable $depends; 2. Edit the main.php file and add the configuration "'yii" under the field "components" \web\JqueryAsset' => ['js' => [],'sourcePath' => null,]," to remove the jquery script.

It's been a week since we talked about the new safe mode bug affecting users who installed KB5012643 for Windows 11. This pesky issue didn't appear on the list of known issues Microsoft posted on launch day, thus catching everyone by surprise. Well, just when you thought things couldn't get any worse, Microsoft drops another bomb for users who have installed this cumulative update. Windows 11 Build 22000.652 causes more problems So the tech company is warning Windows 11 users that they may experience problems launching and using some .NET Framework 3.5 applications. Sound familiar? But please don't be surprised

According to news on December 9, Cooler Master recently demonstrated a mini chassis kit in cooperation with notebook modular solution provider Framework at a demonstration event at the Taipei Compute Show. The unique thing about this kit is that it can be compatible with and Install the motherboard from the framework notebook. Currently, this product has begun to be sold on the market, priced at 39 US dollars, which is equivalent to approximately 279 yuan at the current exchange rate. The model number of this chassis kit is named "frameWORKMAINBOARDCASE". In terms of design, it embodies the ultimate compactness and practicality, measuring only 297x133x15 mm. Its original design is to be able to seamlessly connect to framework notebooks

PHP environment construction guide: common installation points, specific code examples are required. When developing websites or building dynamic web pages, PHP, as a widely used server-side scripting language, is an indispensable tool. This article will introduce how to set up a PHP environment on Windows and Linux systems, including common installation points and actual code examples. I hope it can help readers successfully set up a PHP development environment. 1. Step 1 of setting up PHP environment under Windows system: Download the PHP installation package. First, you need
