Home  >  Article  >  Backend Development  >  How to make an installer in php

How to make an installer in php

藏色散人
藏色散人Original
2020-07-24 09:31:363081browse

How to make an installer in php: first check the permissions of directories and files; then modify the configuration file and modify the configuration file to the filled-in corresponding values; then import the database; and finally establish an initial super system Just an administrator.

How to make an installer in php

I have been very excited recently. I am still the same as when I first learned programming. Although now I look back at the programs I have written, they are all very I am a child and full of loopholes, and I don’t think much about efficiency and safety. However, every time I write a new program or system, I always feel like taking it to compete immediately. It feels great. Although I will look back at this program after a while and find some shortcomings, there is no doubt that such a positive attitude has benefited me a lot. This is what programming is all about, increasing your sense of accomplishment and pride through some small successes, which will make you more interested.

Recommended: "PHP Tutorial"

This medical guidance system was originally developed to meet the company's needs, so I didn't think too much about it. I made it myself. It didn’t last very long, but I skipped the internal testing and tested it while using it. It has been in use for nearly a year now, and the data level is now hundreds of thousands, with several minor modifications and upgrades in between. , it can be regarded as passing the test and running relatively well. So I upgraded it recently, hoping to make a simple universal distribution. So I did the installation process today. The following is a summary of how to install the PHP program.

I won’t write specific code here, but I want to talk about the idea of ​​​​making this installation program. Programs or systems made with PHP are generally BS systems. It is the same whether you use a domain name on the public network or build an environment internally for your own internal use. Therefore, PHP programs are based on the environment. I won’t talk about setting up the environment here. Whether you use integration, etc., it can be used on any server. Here we mainly talk about the implementation of the PHP installation program. All programs are directories and files, and the same is true for PHP.

After the PHP project is completed, the configuration file is usually reserved. The installation program we need to do is to operate this configuration file. If a database is used, we must also operate the database. Let’s talk about the following: How to write a database installation program.

1. Check the permissions of directories and files: Students who have been using win may not pay attention to this, because on win, the permissions of directories are relatively vague, but on linux Above, file permissions are very important, so during the development process, it is necessary to record which directories and files in your project require write permissions, which ones require executable permissions, etc. For those who do not need write permission, it is best not to allow them to have write permission, which will be safer. You can use PHP's function to determine whether the file or directory you specified has the corresponding permissions. If not, give a prompt to let him modify it through ftp or other methods, or you can use PHP's chmod() function to change the specified file or directory. The file is modified to the specified permissions. For example, if your program generates static files or backup files. You need write permission. At this time, the installation program is usually written in a directory called install. You must pay attention to the path of the program inside. We will study it here.

2. Modify the configuration file: Generally, this configuration file is the database configuration file. Of course, sometimes there are also some necessary configuration files for your program. For example, if you define the value of a global variable, you need to install it. Specify it when you specify it, then let the installer fill it in here. After filling in these required configuration variables, you must verify whether they are filled in correctly and whether the configuration can be successful. For example, if it is a database, just link to the database to see if it is correct. Link, when all verifications pass, we can modify the configuration file to the corresponding value he filled in through regular rules, etc.

3. Import the database: There are many ways to import the database. Some people are used to using some phpmyadmin programs, etc., but in some cases the user may only have one account, so To write a database import program, this program is actually very simple. We can clear our database and clear the data table, and then transfer it to a sql file, or other file (php file, of course, the corresponding import program must be Let’s write it. Here we take the simplest sql file exported by mysql as an example), then we read this sql file and execute the sql statement inside (we may sometimes need to filter other things inside, comments, etc. ), of course it can also be written as other database import programs. For example, most of the current import programs can write a dedicated import program for it.

4. Create an initial user: This is easy to understand. It is nothing more than creating an initial super administrator of the system so that you can log in and use it.

But some installation programs may be relatively complicated and have other requirements, such as this medical guidance system. I made two installation programs for users to select. One is the initial installation, which is the first time to use it, and the other is It turns out that there is a medical guidance system written in .net. I revised the .net version and upgraded it. In some cases, the original .net data must be retained and transferred to this program, so a transfer program must be added.

The above is the detailed content of How to make an installer in php. For more information, please follow other related articles on the PHP Chinese website!

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