In the early stage, we only need to download one, which is the core package. We won’t be using the expansion pack for the time being and will download it later. Place the downloaded and unzipped ThinkPHP folder in the root directory of the project we built. We know that our projects require a front and back. So we first create new Home and Admin folders.
When we actually deploy the website, the directory structure often becomes complicated due to the complexity of the project. Our recommended deployment directory structure is as follows:
Directory/File Description
ThinkPHP system directory (the directory structure below is the same as the system directory above)
Public website public resource directory (stores the website’s Css, Js, pictures and other resources)
Uploads website upload directory (unified directory uploaded by users)
Home project directory (the directory structure below is the same as the application directory above)
Admin background management project directory
……More project directories
index.php Entry file of project Home
admin.php Entry file for project Admin
…… More project entry files
If grouping modules are used, it can be simplified to a project directory
Directory/File Description
ThinkPHP system directory (the directory structure below is the same as the system directory above)
App project directory (the grouped directory structure will be described later)
Public website public resource directory (stores the website’s Css, Js, pictures and other resources)
Uploads website upload directory (unified directory for user uploads)
index.php The entry file of the website
The template files of the project are still placed under the Tpl directory of the project, but the externally called resource files, including images, JS and CSS, are placed under the public directory Public of the website and stored in the Images, Js and Css subdirectories. If If possible, these resource files can even be placed on an external server for remote calls and optimized.
Here we choose the second directory method. ThinkPHP requires an entry file, which is index.php under the project root directory. The content is: //Define project name
//Define project name
define('APP_NAME', 'app');
//Define project path
define('APP_PATH', './app/');
/* Data directory*/
define('Egojit_DATA_PATH', './data/');
/* Configuration file directory*/
define('CONF_PATH', Egojit_DATA_PATH . 'config/');
//Load the frame into the file
require './ThinkPHP/ThinkPHP.php';
Why I chose this grouping directory is mainly because I personally think this grouping directory is simpler and clearer. In this way, when we request this website, you will find that many directories will be automatically generated under the app directory. If successful you will see the screen as shown in the picture