Coffee is like a column of life that never envies others ' good, because they believe they can also be good. When you are idle, look at the book, the story in the book, there is always a life you learn.
- catalog view
- Summary view
- Subscription
Async Books: September blockbuster book upgrade, classic
Programmer September Newsletter
Weekly recommendation: ES6, virtual reality, Internet of Things (review book delivery) YII2.0 Configuring the index.php Portal file to the root directoryTags: yii2.0yii2015-10-12 09:53 4060 People read Comments (1) favorite reports Classification:YII2 (7)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
YII2.0 comes with 2 items directory one is the foreground of the frontend and backstage backend, access must be accessed to http://localhost:8080/phpblog/backend/web/index.php?r= Admin/index, this seems to be very troublesome, and difficult to remember, so we have access to the address configured to http://localhost:8080/phpblog/admin.php this is a lot to remember.
First find the Web directory below backend:
Copy the index.php into the root directory and change the name to admin.php:
The contents of the modified admin.php are:
[PHP]View PlainCopy
- <?php
- Defined (' yii_debug ') or define (' Yii_debug ', true);
- Defined (' yii_env ') or define (' yii_env ', ' dev ');
- Require (__dir__. '/vendor/autoload.php ');
- Require (__dir__. '/vendor/yiisoft/yii2/yii.php ');
- Require (__dir__. '/common/config/bootstrap.php ');
- Require (__dir__. '/backend/config/bootstrap.php ');
- #require (__dir__. '/common/config/autoload.php ');
- $config = Yii\helpers\arrayhelper::merge (
- require (__dir__. '/common/config/main.php '),
- require (__dir__. '/common/config/main-local.php '),
- require (__dir__. '/backend/config/main.php '),
- require (__dir__. '/backend/config/main-local.php ')
- );
- $application = new Yii\web\application ($config);
- $application->language=' ZH-CN ';
- $application->defaultroute=' admin ';
- $application->run ();
The following JS,CSS path modifications are made:
Locate the appasset.php below the assets directory under the backend directory to modify the contents
[PHP]View PlainCopy
- Class Appasset extends Assetbundle
- {
- public $basePath = ' @webroot ';
- public $baseUrl = ' @web ';
- //Global JS and CSS, mainly to modify the path here, the original @web can not be used, to write the full path of backend, according to the following write on it
- public $css = [
- ' Backend/web/scripts/css/default.css ',
- ' Backend/web/scripts/js/jquery-easyui-1.4.3/themes/icon.css ',
- ' Backend/web/scripts/js/jquery-easyui-1.4.3/themes/easyui_icons.css ',
- ' Backend/web/scripts/js/jquery-easyui-1.4.3/themes/default/easyui.css '
- ];
- public $js = [
- ' Backend/web/scripts/js/jquery-easyui-1.4.3/jquery.min.js ',
- ' Backend/web/scripts/js/jquery-easyui-1.4.3/jquery.easyui.min.js '
- ];
- public $depends = [
- ];
- //define on-demand loading JS method, note load order at last
- public static function Addscript ($view, $jsfile) {
- $view->registerjsfile ($jsfile, [' depends ' =>[' backend\assets\appasset ']);
- }
- //define on-demand loading of CSS methods, note load order at last
- public static function addcss ($view, $cssfile) {
- $view->registercssfile ($cssfile, [' depends ' =>[' backend\assets\appasset ']);
- }
- }
Continue modifying the main.php below the Config directory under backend:
[PHP]View PlainCopy
- <?php
- $params = Array_merge (
- require (__dir__. '/.. /.. /common/config/params.php '),
- require (__dir__. '/.. /.. /common/config/params-local.php '),
- require (__dir__. '/params.php '),
- require (__dir__. '/params-local.php ')
- );
- return [
- ' id ' = ' app-backend ',
- ' basepath ' = dirname (__dir__),
- ' bootstrap ' = [' log '],
- ' controllernamespace ' = ' backend\controllers ',
- ' components ' = [
[PHP]View PlainCopy
- //Added this configuration
- ' Assetmanager ' = [
- ' basepath ' = ' @webroot/backend/web/assets ',
- ' baseUrl ' = ' @web/backend/web/assets '
- ],
- ' user ' = [
- ' identityclass ' = ' common\models\user ',
- ' enableautologin ' = True,
- ],
- ' log ' = [
- ' TraceLevel ' and yii_debug? 3:0,
- ' targets ' = [
- [
- ' class ' = ' yii\log\filetarget ',
- ' Levels ' = [' error ', ' warning '],
- ],
- ],
- ],
- ' ErrorHandler ' = [
- ' erroraction ' = ' site/error ',
- ],
- ],
- ' Params ' = $params,
The controller must correspond to the configured defaultroute default route, we configure the admin, Then there will be a corresponding admincontroller.php, the inside of the method must be actionindex, so that when the access can be run directly inside the view:
Operating effect:
Hope can help everyone.
-
Top
-
2
-
Step
-
0
- Previous PHP Curl post submission Form
- Next php Compress pictures in a certain proportion to maintain clarity
Related articles recommended
- ? Yii: How to get the root directory
- ? Python Full stack Engineer special training class--Wei Chi
- ? Yii2 find the absolute path to the root directory
- ? Application practice of Blink in Ali group--Chen Shouan
- ? Yii2 Portal File
- ? vue2.x Knowledge Point
- ? YII2.0 directory structure Analysis of official advanced templates
- ? Case analysis of large-scale web architecture design
- ? YII2.0 Configuring the index.php Portal file to the root directory
- ? Machine learning case Study-fraud detection
- ? thinkphp nginx configuration, and rewrite hidden index.php portal file
- ? Android Development 30 minutes integrated third-party SDK
- ? thinkphp Portal File Configuration (index.php file configuration)
- ? YII2 framework Source Tracking reading (i)--from the portal script index.php to the class loader initialization
- ? Thinkphp3.2url rewrite the hidden app's entry file index.php
- ? CI Framework Learning--Hidden Portal file-index.php
View Comments
-
1 floor software expert _20162016-12-10 09:24 published [Reply]
Learning Yii2.0, through this document found, Yii2.0 and easyui combination of usage. Thanks
You are not logged in, please [login] or [register]* above the user's comments on behalf of their personal views, does not represent the views or position of the CSDN website
A hard-working code dog
- Visit: 102,502 times
- Reward Points: 2043
- Grade:
- Rank: 19,800th Place
- Original: 100 Articles
- Reprinted: 9 Articles
- Translation: 0 Articles
- Comments: 24
- Java EE (6)
- Java (7)
- Java design mode (3)
- PHP Development (51)
- JS (1)
- Nodejs (5)
- YII2 (8)
- Android (3)
- MySQL (2)
- Players (1)
- Laravel5 (4)
- PHP design mode (6)
- Web (1)
- Linux (2)
- Nginx (1)
- Vue (1)
- PHP Source Learning (2)
- Automation Testing (3)
- Python (1)
- September 2017 (2)
- August 2017 (3)
- July 2017 (1)
- June 2017 (7)
- May 2017 (1)
Expand
- PHP compresses images by a certain percentage, maintaining sharpness (7107)
- Nginx+obs build streaming media to achieve live (5975)
- Nodejs,async Synchronous Execution Method (4306)
- YII2.0 Configuring the index.php Portal file to the root directory (4057)
- MyBatis automatically generates entity classes, mapping files, and DAO layer interfaces. (4028)
- YII2 set up routing access, beautify URLs (4002)
- PHP self vs. static difference (3663)
- Beginner Nodejs Connection MySQL simple landing implementation (3089)
- Jwplayer player Basic use (3043)
- YII2 using CONTROLLERMAP Custom controller class (2810)
- Nginx+obs build streaming media to achieve live (9)
- PHP CSV bulk Data Export segmentation processing (3)
- PHP Phone get 6 for non-duplicate verification Code (2)
- PHP compresses images by a certain percentage, maintaining sharpness (2)
- Beginner Nodejs Connection MySQL simple landing implementation (2)
- PHP Session Store database (1)
- YII2.0 Configuring the index.php Portal file to the root directory (1)
- Apache Agent Nodejs (1)
- PHP Registered Tree mode (1)
- MyBatis automatically generates entity classes, mapping files, and DAO layer interfaces. (1)
- * CSDN New Blog Feed Flow Beta user Solicitation Order
- * Android Check update download install
- * Create the simplest recycleview slide menu in history
- * How TCP network communication solves the problem of packet sticking
- * SDCC 2017 Big Data technology on the real Front summit
- * Fast integration of one video live function
- PHP compresses images at a certain percentage to maintain clarity
A diligent code dog: @qq_32125563: Custom Path $src = $path/001.jpg&quot;;
- MyBatis automatically generates entity classes, mapping files, and DAO layer interfaces.
Majinqi_: Directly find the XML file right-click Generator MyBatis
- PHP compresses images at a certain percentage to maintain clarity
qq_32125563: How do I choose the path to the picture?
- PHP CSV bulk Data export segmentation processing
Like Yi: nn. After I directly exported, the actual data volume is not particularly large, so it can be exported with pagination.
- Beginner Nodejs Connection MySQL simple landing implementation
A diligent code dog: @m0_37729793: Https://git.oschina.net/xuxu.gao/node ...
- Nginx+obs to build streaming media for live broadcast
A diligent code dog: @wang2364116142: Maybe it's your network problem that shuts down obs delays.
- PHP CSV bulk Data export segmentation processing
A diligent code dog: @u011151452: I write the data according to the different parts in the way of paging, should not be memory overflow
- Nginx+obs to build streaming media for live broadcast
wang2364116142: @gyu2010: Why I use H5 's video tag, I can't use it.
- Nginx+obs to build streaming media for live broadcast
wang2364116142: Do not know what is the problem, too card, delay
- PHP CSV bulk Data export segmentation processing
Like Iraq: When the amount of data is much, can be in batches. I always complain. But I took the data out at once. Then split, exit I also write ...
-
Company Profile | careers | Advertising SERVICES | contact | copyright | Legal Counsel | PROBLEM Report | partners | Forum Feedback
-
website Customer Service magazine customer Service Micro Blog service [email protected] 400-660-0108| Beijing Innovation Music Information Technology Co., Ltd. Copyright | Jiangsu knowledge for Computer Co., Ltd. | Jiangsu le know Network Technology Co., Ltd.
-
Beijing ICP certificate No. No. 09002463 | Copyright? 1999-2017, csdn.net, All rights Reserved
index.php the entry file to the root directory