In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to build and use ThinkPHP5 quickly". In daily operation, I believe many people have doubts about how to build and use ThinkPHP5 quickly. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to build and use ThinkPHP5 quickly"! Next, please follow the editor to study!
Installation of 0X01 Thinkphp
What I choose here is to use composer under windows to install, accept the first download composer this tool, after the installation is completed, enter the folder where we want to create the project, enter the following command
Composer create-project topthink/think tp5 dev-master-prefer-dist
This will form a folder called tp5 under the current directory, which contains the basic framework of thinkphp5.
Introduction of 0X02 key directory structure and files
1. Directory structure
Application: application directory, our model view controller will be placed in this folder, this is the main position of our development.
Public: this is the entry file for our project. Thinkphp is a single entry framework.
Thinkphp: the core directory of the framework
two。 Key document
Application/config.php project configuration file, turning on debug debug mode (in development)
Application/database.php database configuration file
The public/index.php project entry file, which defines the location of the application directory and contains the framework startup file to start the framework
0X03 configure virtual host
In 1.httpd.conf, determine whether the following is commented, and if so, please uncomment
(1) Include conf/vhosts.conf (2) LoadModule vhost_alias_module modules/mod_vhost_alias.so
two。 Delete the original default content in vhost.conf and add the following
DocumentRoot "E:\ phpstudy\ PHPTutorial\ WWW\ tp5\ public" ServerName localhost Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted
3. Configure URL rewriting
Unlock the following comments in http.conf
LoadModule rewrite_module modules/mod_rewrite.so
And write it in the virtual host configuration
AllowOverride All
Note: if you use phpstudy, the official default .htaccess is not allowed and needs to be modified to look like this
RewriteEngine on RewriteCond% {REQUEST_FILENAME}!-d RewriteCond% {REQUEST_FILENAME}!-f RewriteRule ^ (. *) $index.php
The basic way to write 0X04
1. The basic writing method of controller
(1) the controller in the module is actually a class. When this class is written, it inherits Controller and writes the namespace before it.
(2) thinkPHP5 uses return to return a html, which is automatically rendered to the page.
(3) tp5 uses $this- > requrst- > param () to accept parameters and, of course, to write a namespace at the beginning
Sample code:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.