Provides various official and user-released code examples. For code reference, you are welcome to exchange the learning documentation. Most of the content is from the Internet.
Preparations
Download the latest ThinkPHP3.2 (http://www.thinkphp1.cn/download/502.html );
ThinkPHP development tool Zend Studio 7.2.1 (there are no restrictions on tools, depending on your preferences, and some prefer Sublime Text)
Template Development Tool Dreamweaver CS6 (optional)
1. Set up an empty project
(01) create a new project in Zend Studio named StudyFoxShop
(02) decompress the ThinkPHP3.2 package and copy all the extracted files to the project folder.
(03) deployment project
(04) Add the project to the website management of Dreamweaver
2. Run the project
Press Ctrl + F in Dreamweaver. The search box is displayed. The search scope is "entire local site", the search is "Home", and click search all, double-click the search result at the bottom and make the following changes:
'Default _ module' => 'home', // DEFAULT MODULE
To:
'Default _ module' => 'admin', // background MODULE
Namespace Home \ Controller;
To:
Namespace Admin \ Controller;Project running successfully:
:)
Welcome to ThinkPHP!
Delete the Common and Runtime folders under the project directory Application.
3. Run the project again
In step 2, press Ctrl + F in Dreamweaver to bring up the search box. The search scope is "the entire local site", search: "Admin", and click search all, double-click the search result at the bottom and make the following changes:
'Default _ module' => 'admin', // DEFAULT MODULE
To:
'Default _ module' => 'index', // foreground MODULE
Namespace Admin \ Controller;
To:
Namespace Index \ Controller;After the project runs successfully, it is displayed again:
:)
Welcome to ThinkPHP!
The project is run twice because the mall system is divided into the front and back ends and can be run once. Then, the whole module (called the project in version 3.1.3) is copied and modified. The automatic generation speed is relatively fast and error-prone.
4. Foreground directory Adjustment
(01) All contents in the public directory of the original project except the thinkphp folder are copied to the Public directory of the new project.
(02) the config. php In the root directory of the original project overwrites the Application \ Common \ Conf directory of the new project.
(03) create a configuration file in the new project Application \ Index \ Conf and add the configuration items in the original project index \ Conf \ config. php.
(04) create a configuration file in the new project Application \ Admin \ Confnf and add the configuration items in the original project admin \ Conf \ config. php.
(05) copy the Common. php file in the original project index \ common to the new project Application \ Index \ Common and change it to function. php.
(06) delete IndexController from the new project Application \ Index \ Controller. class. PHP file, and copy all the files in the original project index \ Lib \ Action to the new project Application \ Index \ Controller directory, at the same time, change "Action" in the file name to "Controller" (the file name can not be modified, you only need to add the configuration item 'default _ C_LAYER '=> 'action, but it is convenient to be consistent with ThinkPHP official. We recommend that you use the "Controller" name to make it more reasonable)
(07) Open the Application \ Index \ Controller \ IndexController. class. php file of the new project in Zend Studio, and add
namespace Index\Controller;
use Think\Controller;(08) modify the code class IndexAction extends Action
class IndexController extends Controller(09) the new project Application \ Index \ Controller \ LoginController. class. php file is operated in steps 4.7 and 4.8 (note that the class name needs to be modified accordingly)
(10) copy the index \ Lib \ Model \ CategoryModel. class. php file of the original project to the Application \ Index \ Model folder of the new project, open it with Zend Studio, and add
namespace Index\Model;
use Think\Model\RelationModel;(11) Copy all content from the original project index \ Tpl to the new project Application \ Index \ View folder.
(12) Delete the Runtime folder under the new project Application and run the project in the browser. The homepage and logon page of the mall can be opened normally.
5. Background directory Adjustment
(01) delete IndexController from the new project Application \ Admin \ Controller. class. php document, copy all files in the original project admin \ Lib \ Action to the new project Application \ Admin \ Controller directory, and change "Action" in the file name to "Controller"
(02) Open the Application \ Index \ Controller \ CommonController. class. php file of the new project in Zend Studio, and add
namespace Admin\Controller;
use Think\Controller;
use Think\Page;(03) change the code class CommonAction extends Action
class CommonController extends Controller(04) the method for modifying other files is similar, as follows:
(05) Modify AuthGroupController. class. php
namespace Admin\Controller;
use Think\Controller;
class AuthGroupController extends CommonControllerOther files can be successfully upgraded by modifying the above method.
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB