thinkphp3.1 project development and deployment
Download ThinkPHP 3.1.3 The file structure after decompression of the framework package:
├─ Common Framework public file directory
├─ Conf Framework configuration file directory
├─ Extend framework extension directory
├─ Lang framework system language directory
├─ Lib system core base class library directory
│ ├─ Behavior built-in behavior class library
│ ├─ Core Class library package
│ ├─ Driver built-in driver class library package
│ │ ├─ Cache built-in cache driver
│ │ ├─ Db built-in database driver
│ │ ├─ TagLib built-in tag driver
│ ├─ Template built-in template engine driver
├─ Tpl system template directory
├─ ThinkPHP.php framework entry file
New project entry file index.php
<?php require './ThinkPHP/ThinkPHP.php';
Access the project in the browser, the page displays:
At this time, the files under the project directory app have changed. Except for the entry file index.php and the framework package, all other files have changed. It is automatically generated:
The functions of each folder:
├─ Common Project public file directory
├─ Conf Project configuration directory
├─ Lang Project language package directory
├─ Lib Project class library directory
│ ├─ Action Action class library directory
│ ├─ Behavior Behavior class library directory
│ ├─ Model model Class library directory
│ ├─ Widget Widget class library directory
├─ Runtime Project runtime directory
│ ├─ Cache Template cache directory
│ ├─ Data Data cache directory
│ ├─ Logs Log file directory
│ ├─ Temp Temporary cache directory
├─ ThinkPHP Framework directory
├─ Tpl Project template directory
├─ index.php Project entry file
The entry file index.php in this method is stored in the project directory. You can also move the entry file outside the app directory and modify the entry file index.php:
<?php //定义项目名称 define('APP_NAME', 'Application'); // 定义项目路径 define('APP_PATH', './Application/'); //加载框架入口文件 require './ThinkPHP/ThinkPHP.php';
Directory structure:
There are two project deployment methods, one It is application deployment. Each project corresponds to an entry file. For example, the front-end entry file corresponds to index.php, and the back-end entry file corresponds to admin.php. This kind of project deployment is the recommended method of ThinkPHP;
Front-end entry file:
<?php define('APP_NAME', 'Home'); define('APP_PATH', './Home/'); require './ThinkPHP/ThinkPHP.php';
Back-end entry file:
<?php define('APP_NAME', 'Admin'); define('APP_PATH', './Admin/'); require './ThinkPHP/ThinkPHP.php';
The other is module group deployment, which maps all applications to one entry file, and the project template file is still placed Go to the Tpl directory of the project and just put the externally called resource files, including images JS and Css, under the public directory Public of the website, and store them in the Images, Js and Css subdirectories. If possible, you can even put these The resource file is placed separately for remote calling by an external server and optimized.
Module grouping needs to configure APP_NAME and APP_PATH;
Create the project directory App in the WEB root directory, and copy the framework package ThinkPHP to the same level directory, and at the same time At the same level, create the public resource directory Public for all projects, the public upload directory Uploads for all projects, and the entry file index.php:
The entry file index.php:
<?php define('APP_NAME', 'App'); define('APP_PATH', './App/'); //开启debug,不加载缓存文件 define('APP_DEBUG', true); require './ThinkPHP/ThinkPHP.php';
Access index.php through url. After initializing the project environment, the automatically generated directory under the App directory:
Then in the App/Conf/config.php configuration file, configure Grouping options:
<?php return array( //'配置项'=>'配置值' 'APP_GROUP_LIST' => 'Admin,Home', 'DEFAULT_GROUP' => 'Home', );
If you access the index.php entry file at this time, ThinkPHP will report an error:
Because module grouping is enabled in the public configuration file, However, the corresponding group directory has not been created, and the respective configuration files of the Admin and Home groups need to be manually created: Create the Admin and Home directories under the Conf directory.
Then create config.php configuration files in the directories respectively; the App/Lib/Action directory also needs to create the Admin and Home directories, and then move the default created IndexAction.class.php file to App/Lib/Action /Home directory, no error will be reported when accessing the entry file, and the project deployment is successful:
If you hide the entry file, the URL addresses of the two will look almost the same:
Recommended tutorial: "TP5 》
The above is the detailed content of thinkphp3.1 project development and deployment. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

ThinkPHP is a high-performance PHP framework with advantages such as caching mechanism, code optimization, parallel processing and database optimization. Official performance tests show that it can handle more than 10,000 requests per second and is widely used in large-scale websites and enterprise systems such as JD.com and Ctrip in actual applications.

Development suggestions: How to use the ThinkPHP framework for API development. With the continuous development of the Internet, the importance of API (Application Programming Interface) has become increasingly prominent. API is a bridge for communication between different applications. It can realize data sharing, function calling and other operations, and provides developers with a relatively simple and fast development method. As an excellent PHP development framework, the ThinkPHP framework is efficient, scalable and easy to use.

"Development Suggestions: How to Use the ThinkPHP Framework to Implement Asynchronous Tasks" With the rapid development of Internet technology, Web applications have increasingly higher requirements for handling a large number of concurrent requests and complex business logic. In order to improve system performance and user experience, developers often consider using asynchronous tasks to perform some time-consuming operations, such as sending emails, processing file uploads, generating reports, etc. In the field of PHP, the ThinkPHP framework, as a popular development framework, provides some convenient ways to implement asynchronous tasks.
