index.php the entry file to the root directory

Source: Internet
Author: User
Tags autoload php session vars yii

    • Login | Registered
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
  1. <?php
  2. Defined (' yii_debug ') or define (' Yii_debug ', true);
  3. Defined (' yii_env ') or define (' yii_env ', ' dev ');
  4. Require (__dir__.  '/vendor/autoload.php ');
  5. Require (__dir__.  '/vendor/yiisoft/yii2/yii.php ');
  6. Require (__dir__.  '/common/config/bootstrap.php ');
  7. Require (__dir__.  '/backend/config/bootstrap.php ');
  8. #require (__dir__.  '/common/config/autoload.php ');
  9. $config = Yii\helpers\arrayhelper::merge (
  10. require (__dir__. '/common/config/main.php '),
  11. require (__dir__. '/common/config/main-local.php '),
  12. require (__dir__. '/backend/config/main.php '),
  13. require (__dir__. '/backend/config/main-local.php ')
  14. );
  15. $application = new Yii\web\application ($config);
  16. $application->language=' ZH-CN ';
  17. $application->defaultroute=' admin ';
  18. $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
  1. Class Appasset extends Assetbundle
  2. {
  3. public $basePath = ' @webroot ';
  4. public $baseUrl = ' @web ';
  5. //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
  6. public $css = [
  7. ' Backend/web/scripts/css/default.css ',
  8. ' Backend/web/scripts/js/jquery-easyui-1.4.3/themes/icon.css ',
  9. ' Backend/web/scripts/js/jquery-easyui-1.4.3/themes/easyui_icons.css ',
  10. ' Backend/web/scripts/js/jquery-easyui-1.4.3/themes/default/easyui.css '
  11. ];
  12. public $js = [
  13. ' Backend/web/scripts/js/jquery-easyui-1.4.3/jquery.min.js ',
  14. ' Backend/web/scripts/js/jquery-easyui-1.4.3/jquery.easyui.min.js '
  15. ];
  16. public $depends = [
  17. ];
  18. //define on-demand loading JS method, note load order at last
  19. public static function Addscript ($view, $jsfile) {
  20. $view->registerjsfile ($jsfile, [' depends ' =>[' backend\assets\appasset ']);
  21. }
  22. //define on-demand loading of CSS methods, note load order at last
  23. public static function addcss ($view, $cssfile) {
  24. $view->registercssfile ($cssfile, [' depends ' =>[' backend\assets\appasset ']);
  25. }
  26. }
Continue modifying the main.php below the Config directory under backend:

[PHP]View PlainCopy
  1. <?php
  2. $params = Array_merge (
  3. require (__dir__. '/.. /.. /common/config/params.php '),
  4. require (__dir__. '/.. /.. /common/config/params-local.php '),
  5. require (__dir__. '/params.php '),
  6. require (__dir__. '/params-local.php ')
  7. );
  8. return [
  9. ' id ' = ' app-backend ',
  10. ' basepath ' = dirname (__dir__),
  11. ' bootstrap ' = [' log '],
  12. ' controllernamespace ' = ' backend\controllers ',
  13. ' components ' = [
[PHP]View PlainCopy
  1. //Added this configuration
  2. ' Assetmanager ' = [
  3. ' basepath ' = ' @webroot/backend/web/assets ',
  4. ' baseUrl ' = ' @web/backend/web/assets '
  5. ],
  6. ' user ' = [
  7. ' identityclass ' = ' common\models\user ',
  8. ' enableautologin ' = True,
  9. ],
  10. ' log ' = [
  11. ' TraceLevel ' and yii_debug? 3:0,
  12. ' targets ' = [
  13. [
  14. ' class ' = ' yii\log\filetarget ',
  15. ' Levels ' = [' error ', ' warning '],
  16. ],
  17. ],
  18. ],
  19. ' ErrorHandler ' = [
  20. ' erroraction ' = ' site/error ',
  21. ],
  22. ],
  23. ' 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
      Personal Information

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
      Article Search
      article Categories
    • 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)
      Article archive
    • September 2017 (2)
    • August 2017 (3)
    • July 2017 (1)
    • June 2017 (7)
    • May 2017 (1)
Expand
      Read the rankings
    • 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)
      Comment Ranking
    • 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)
      Featured Articles
      • * 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
      Latest Comments
    • PHP compresses images at a certain percentage to maintain clarity

      A diligent code dog: @qq_32125563: Custom Path $src = $path/001.jpg&amp;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.