Windows 上界面美观的 PHP 集成环境软件

界面展示一下:

clipboard.png

源码:SalamanderWnmp
集成包下载 http://ongd1spyv.bkt.clouddn.com/Salamande...
喜欢的童鞋 star 一个哦

原因#

平常工作中用 Nginx 比较多,网上虽然也有 wnmp 集成环境,但是感觉界面不好看,用起来不舒服,所有决定自己做一个吧。

原料#

软件用的是 C#,GUI 框架是 WPF(这个做出来更好看一点),先去官网下载 PHP,用的是 NTS 版本的(因为这里 PHP 是以 CGi 的形式跑的),再去下载 Windows 版的 NginxMysql

代码#

基类#

代码已被折叠,点此展开

开启 mysql 代码:#

代码已被折叠,点此展开

开启 php 代码:#

class PHPProgram : WnmpProgram
    {
        public PHPProgram()
        {
            ps.StartInfo.EnvironmentVariables.Add("PHP_FCGI_MAX_REQUESTS", "0"); // Disable auto killing PHP
        }

        private string GetPHPIniPath()
        {
            return MainWindow.StartupPath + "/" + Settings.PHPDirName.Value + "/php.ini";
        }

        public override void Start()
        {
            if(this.IsRunning())
            {
                return;
            }
            uint ProcessCount = Settings.PHP_Processes.Value;
            short port = Settings.PHP_Port.Value;
            string phpini = GetPHPIniPath();

            try {
                for (var i = 1; i <= ProcessCount; i++) {
                    StartProcess(exeName, String.Format("-b localhost:{0} -c {1}", port, phpini));
                    Log.wnmp_log_notice("Starting PHP " + i + "/" + ProcessCount + " on port: " + port, progLogSection);
                    port++;
                }
                Log.wnmp_log_notice("PHP started", progLogSection);
            } catch (Exception ex) {
                Log.wnmp_log_error("StartPHP(): " + ex.Message, progLogSection);
            }
        }

    }

开启 nginx#

####### 这里要注意 WorkingDirectory 属性设置成 nginx 目录,这里是 setup 代码

   private readonly WnmpProgram nginx = new WnmpProgram();

   private void SetupNginx()
        {
            nginx.Settings = Settings;
            nginx.exeName = StartupPath + String.Format("{0}/nginx.exe", Settings.NginxDirName.Value);
            nginx.procName = "nginx";
            nginx.progName = "Nginx";
            nginx.workingDir = StartupPath + Settings.NginxDirName.Value;
            nginx.progLogSection = Log.LogSection.WNMP_NGINX;
            nginx.startArgs = "";
            nginx.stopArgs = "-s stop";
            nginx.killStop = false;
            nginx.statusLabel = lblNginx;
            nginx.confDir = "/conf/";
            nginx.logDir = "/logs/";
        }

其他功能#

配置 nginx,php,mysql 目录名,管理 php 扩展

clipboard.png

clipboard.png

编程语言面板#

clipboard.png

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。