Thinkphp Learning (2) Clarify thinkphp directory structure and access rules, create the first controller

Source: Internet
Author: User
Thinkphp Learning (ii) Clarify thinkphp directory structure and access rules, create the first controller

Directory Structure of the thinkphp

Review the installation directory of the previous article:


Directory Correspondence Relationship

f:\\php
├─index.php Portal File
├─readme.md README File
├─application application Directory
├─public Resource File directory
└─thinkphp Framework Catalog


Directory Structure of the thinkphp

The thinkphp directory structure is very clear and easy to deploy. The approximate directory structure is as follows, and is deployed on a project basis.

┎━thinkphp Framework system catalog
┃┝ thinkphp.php system Public File
┃┝common common file directory
┃┝TPL framework System template Directory
┃┝lang system Language Pack directory
┃┝plugins Common plug-in directory
┃┗lib system base Class Library Directory Br>┃┝think System Runtime (required)
┃┝com Extension Class Library package (not required)
┃┗org Extension Class Library package (not required)

┝━application application directory, project directory
┃┝index.php project portal file (can be placed arbitrarily)
┃┝cache template Cache directory
┃┝common common file directory (not required)
┃┝conf project configuration directory
┃┝data Project Data Directory
┃┝html static file directory (not required)
┃┝plugins plug-in directory (not required)
┃┝tpl template file directory
┃┝lang Language Pack directory (not required)
┃┝logs log Text Item directory
┃┝temp data cache directory
┃┗lib apply class Library Directory
┃┝action Controller (module) class directory
┃┝model Model class file directory
┃ ... The following application directory can select and define the
┃┝exception Exception Class Library directory
┃┝common Common Application class directory
┃┗help helper class directory

┃ ... as needed. More project catalogs (similar to app directories, each with a separate directory for easy deployment)

┝━public Web site Public directory (multi-project public)
┃┝js Js Class Library directory (recommended)
┃┝images Common Image directory (recommended)
┃┗up Loads public upload directory (recommended)


My "F:\PHP\Application" directory has a "home" directory, which is a thinkphp automatically generated by a controller,

The main document is "F:\PHP\Application\Home\Controller\IndexController.class.php", the file content is as follows:

 
  Show ('

:)

thinkphp!

', ' utf-8 ');} }

Enter "http://localhost/index.php" in the Address bar, carriage return, what you see is the content of the "index" function in this file.

Access rules

for an example of a controller under the "Home" directory, you can access it via the following URL address:

http://localhost/index.php

Http://localhost/index.php/Home

Http://localhost/index.php/Home/Index

Http://localhost/index.php/Home/Index/Index

Create the first controller

Create a new directory in the "F:\PHP\Application" directory "Index", Steal a Lai, the "F:\PHP\Application\Home" directory of the contents are copied

To the "F:\PHP\Application\Index" directory, open the "F:\PHP\Application\Index\Controller\IndexController.class.php" file,

To make sure that the access is really our new additions, add something to the "Index" function with the following code:

 
  Show ('//phpinfo ();
$this->show ('

:)

thinkphp AAAA!

', ' utf-8 '); $this->show (' function index ()
');}}
Try using the following URL to access it:
Http://localhost/index.php/Index

Http://localhost/index.php/Index/Index

Http://localhost/index.php/Index/Index/Index

  • 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.