search
Homephp教程PHP开发Quick Start with Yii (1)

Quick Start with Yii (1)

Dec 20, 2016 am 11:07 AM
yii

Please indicate the source when reprinting: Yii Quick Start (1)

Ⅰ. Basic concepts
1. Entry file
Entry file content: The general format is as follows:

$yii=dirname(__FILE__).'/../../framework/yii.php';/ /Yii framework location
$config=dirname(__FILE__).'/protected/config/main.php';//The main configuration file location of the current application

// When deploying the formal environment, remove the following line
// defined('YII_DEBUG') or define('YII_DEBUG',true);//Whether to run in debug mode

require_once($yii);//Contains Yii framework
Yii::createWebApplication($config)->run ();//Create an application instance based on the main configuration file and run it. You can access this instance through Yii::app() from anywhere in the current application.


2. Main configuration file
Save location: your application/protected/config/main.php
File content: The general format is as follows:
return array(
'basePath'=>dirname(__FILE__ ).DIRECTORY_SEPARATOR.'..', //The absolute physical path of the current application root directory
'name'=>'Yii Blog Demo', //The name of the current application

//Preload the log (record) application Components, which means that the application components will be created regardless of whether they are accessed. The application's parameter configuration is set in the array with "components" as the keyword below.
'preload'=>array('log'), //log is the component ID

//Auto-loaded model and component class
'import'=>array(
'application.models.*', //Load the "application/models/" folder All model classes
        'application.components.*', //Load all application component classes in the "application/components/" folder
   ),

  'defaultController'=>'post', //Set the default control Device class

// Component configuration of the current application. For more configuration components, see "Core Application Components" below
'components'=>array(
'user'=>array( //user( User) component configuration, "user" is the component ID
              // Cookie-based authentication can be used
            'allowAutoLogin'=>true, // Allow automatic login
                                                                                                             
                                                                                                                                                                ,,,,,,,,,,,,,,,,,,,,,, , 'port'=> 11211, 'weight'=>60), //Cache server 1
                               array('host'=>'server2', 'port'=>11211, 'weight'=>40), //Cache server 2
  // DSN string to connect to the database
        'tablePrefix' => 'tbl_', //Data table prefix
          ),
          // If you want to use a MySQL database, please uncomment the following
             
    'errorHandler'=> Array (使用 // uses the ActionError method in the SiteController controller class to display the error
'erraraction' = & gt; 'site/error', // When encountering errors, run operations. The controller name and method name are all lowercase and separated by slashes "/"
      ),
    //URL routing manager
    'urlManager'=>array(
            'urlFormat'=>'path', //URL format. Two formats are supported: 'path' format (such as: /path/to/EntryScript.php/name1/value1/name2/value2...) and 'get' format (such as: /path/to/EntryScript.php? name1=value1&name2=value2...). When using the 'path' format, you need to set the following rules:
            'rules'=>array( //URL rules. Syntax:
                                                                                                                                                       >/<.>&title
<.>









































































































&











































































































































































































































































































































































































''''
 



 
   
 
   

       
       
   

 
   

       
       
   

 
   

       
       
   

 
   

       
   

 




 

''
 
   
 
   

       ''
       ''
   

 
   

       ''
       ''
   

 
   

       ''
       ''
   

 
   

       
   

 

































Statement
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

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft