Home >php教程 >php手册 >thinkphp installation bootloader

thinkphp installation bootloader

WBOY
WBOYOriginal
2016-10-19 10:18:171452browse

thinkphp installation guide
If you still don’t know what installation guide is;
Then download the project first; put it in the php environment and run it and you will know;
Sample project: https://github.com/baijunyao/thinkphp-bjyadmin
Why does our program need an installation guide?
1. There is an installation guide; we don’t need to explain at length how to import sql files; how to change configuration items;
2. You can write some copyright or instructions for use;
3. You can do some tests on the environment first;

Here is a simple installation and guidance process tailor-made for thinkphp purely by hand;
Of course; more importantly; this installation can be independent of thinkphp;
If you want to use it in other projects; it can also be transplanted very conveniently;
Copy the directory; add a few lines of code and you’re done;

1: Import the installation boot program
/Public/install/
Put the install in the directory of your project;
The important thing inside is bjyadmin.sql. This is the database file;
And in the initial state; there is no install.lock file;

Two: Check whether /index.php<br> is installed // Check whether it is a new installation<br> if(file_exists("./Public/install") && !file_exists("./Public/install/install.lock")){<br> //Assembly and installation url<br> $url=$_SERVER['HTTP_HOST'].trim($_SERVER['SCRIPT_NAME'],'index.php').'Public/install/index.php';<br> // Use http:// domain name to access; avoid ./Public/install path compatibility and other errors<br> Header("Location:http://$url");<br>        die;<br> }In the entry file; added a piece of code to detect whether it is installed;

Three: Process
First; when accessing index.php;
The above code will be executed first; determine whether the /Public/install/install.lock file exists;
If it does not exist; it means it has not been installed yet;
It will be redirected to /Public/install/index.php to follow the installation program;
When the database account and password are entered as required and the installation is successful;
A /Public/install/install.lock file will be created;
When accessing the entry file again; the redirection will be skipped;
At the same time, the entered database account password will be written to the /Application/Common/Conf/db.php file;
This is also a summary of thinkphp’s directory structure design experience http://baijunyao.com/article/60 in this article;
The reason why you need to create a separate db.php file;

The installation process is written in the /Public/install/index.php file;
But I don’t plan to introduce it in this article, because... I am too lazy to write;
Detailed comments have been given inside; just look at the source code;

thinkphp installation bootloader

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn