繁体   English   中英

如何为PHP应用程序创建安装程序?

[英]How can I make an installer for a PHP application?

我有一个PHP应用程序,并希望为它创建一个安装程序。 我可以使用任何现有的框架吗? 有关这类事情的任何好的教程吗?

您需要的不是安装程序而是编译器。

看看这篇文章:

http://www.swiftlytilting.com/2005/03/21/phc-a-php-to-exe-compiler/

请查看http://winbinder.org/http://gtk.php.net/

这些工具可帮助您使用PHP作为编程语言创建桌面应用程序。

安装程序?

如果您正在安装PHP脚本/设置一些设置/等,那么是。 vBulletin和phpBB有一些很棒的'安装程序' - 他们创建一个配置文件而不需要弄脏。

但是,如果你在谈论Windows / Linux / OS X /等。 可执行安装程序,我认为你不能。

PHP脚本安装系统创建

图像预览

在根文件夹(htdocs)中创建两个新文件夹(包括并安装)。 在include文件夹中创建新文件connect.phpDB_Info.php 在代码编辑器中打开connect.php并在connect.php中编写@mysql_connection代码 始终使用connect.php文件包含/要求连接数据库的文件|

<?php  // Always Include/Require This File For Connect Database
    require_once "DB_Info.php";  // this is connect.php file

    @mysqli_connect(
        $HOST_name,
        $DB_username,
        $DB_password
    ) or die(
        "<h2>Database Error, Contact With Admin </h2>"
    );

    @mysqli_select_db(
        $DB_name
    ) or die(
        "<h2>Database Error, Contact With Admin</h2>"
    );
?>

require_once DB_Info.php保持空白| 你可以在connect.php中看到$ HOST_name,$ DB_username,$ DB_password var没有值| 我们在DB_Info.php(require file)|中提供表单中的值 现在创建index.phpinstal.phpinstalled.php三个文件进入安装文件夹 1st index.php创建表单 - >

<link rel='stylesheet' href='style.css' />

<?php  // create form
    $HOST_name = "<input class='input' type='text' name='dbhost' placeholder='Enter Host Name' />";
    $DB_username = "<input class='input' type='text' name='dbuser' placeholder='Enter DB User Name' />";
    $DB_password = "<input class='input' type='password' name='dbpass' placeholder='***********' />";
    $DB_name = "<input class='input' type='text' name='dbname' placeholder='Enter DB Name' />";
    echo "<div class='box' >
            <form class='ins' method='post' action='installing.php' >
                    <p>Enter Host Name:<p>
                    $HOST_name
                    <p>Enter DB User Name:<p>
                    $DB_username
                    <p>Enter DB PassWord:<p>
                    $DB_password
                    <p>Enter DB Name:<p>
                    $DB_name
                    <input class='submit' type='submit'name='install' value='NEXT' />
            </form>
        </div>";
?>

表单操作是安装 .php现在我们使用文件处理函数fwrite()将三个var值写入DB_Info.php (connect.php $ HOST_name,$ DB_username,$ DB_passwordInstalling.php- >

<link rel='stylesheet' href='style.css' />
<?php  
    $writer="<?php".'
    '.'$HOST_name = '."'".$_POST['dbhost']."'".';
    '.'$DB_name = '."'".$_POST['dbname']."'".';
    '.'$DB_username = '."'".$_POST['dbuser']."'".';
    '.'$DB_password = '."'".$_POST['dbpass']."'".';
    '."?>";

    $write=fopen('..\include/DB_Info.php' , 'w');
    if(empty($_POST['dbhost']&&
             $_POST['dbname']&&
             $_POST['dbuser']&&
             $_POST['dbpass'])){
                 echo"<h2 align=center >All Fields are required! Please Re-enter</h2>";

    }else{
        if(isset($_POST['install']))
        {
            fwrite($write,$writer);
            fclose($write);
            echo "<div class='box'>
                <form class='ins' action='installed.php' method='post'>
                    <h2 align=center color=red>Database Info Succecfully Entered<h2>
                    <input class='submit' type='submit' value='NEXT' name='next'/>
                </form>
                </div>";
        }else{ echo "<h2 align=center >Error<h2>"; }}
?>

最后一步安装 .php用于创建表到phpmyadmin - >

<?php
    if(isset($_POST['next'])){
        /*  enter your
         sql code for
         teble creating */
        echo"<h2 align=center >Finished</h2>";
    }else{
        echo"<h2 align=center >Error</h2>";
    }
?>

我们的CSS

* {
    margin: 0;
    padding: 0;
}

.box {
    position: absolute;
    width: 300px;
    top: 16%;
    left: 35%;
    background-color: rgb(0, 0, 0);
    padding: 15px;
    padding-top: auto;
}

.ins {
    margin: 0;
    padding: 0;
    font-weight: bold;
    color: lawngreen;
    font-size: 1rem;
}

.input {
    border: none;
    border-bottom: 2px solid lawngreen;
    margin-bottom: 20px;
    width: 100%;
    height: 40px;
    background: transparent;
    outline: none;
    color: cyan;
    font-size: 1rem;
}

.submit {
    background-color: lawngreen;
    width: 100%;
    height: 40px;
    font-size: 1.5rem;
    border: none;
    margin-top: 10px;
    outline: none;
    cursor: pointer;
    border-radius: 20px;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM