运行PHP脚本就像没有浏览器的应用程序 [英] Run PHP script like an application without Browser

查看:146
本文介绍了运行PHP脚本就像没有浏览器的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是新来的PHP,而且不知道是什么,如果我要问,甚至有可能还是它甚至有意义但在这里不用。

Hi I am new to PHP and have no idea if what I am about to ask is even possible or does it even make sense but here goes.

我想,如果我执行web服务器上的一个独立的应用程序来执行PHP脚本,我想实现的是,当客户购买的东西在网站上,一次他看到网站上的付款确认通知,他应该被允许关闭浏览器窗口或注销,而不会影响大的订单生成的过程,得到的开始,一旦用户被送到这显示他所做的支付成功的页面。

I want to execute a PHP script as if I am executing a standalone application on the WebServer, what I am trying to implement is that when the Customer purchases something on the website and the once he sees the payment confirmation notice on the website, he should be allowed to close the browser window or logoff without affecting the big order generation process that get's started once the user is taken to the page that displays that the payment that he made was successful.

现在我利用AJAX的打电话给我付款后处理PHP脚本,并一直保持该脚本忽略任何用户中断通话。

Right now I am making use of AJAX to call my after payment processing PHP script and have kept that script to ignore any user abort call.

这是告诉付款已成功接收到的用户的页面。

This is the page that tells the user that the payment was received successfully.

thankyou.php

这是执行只需要成功的付款收据

This is the page that performs the processing that needs to be done only after successful receipt of payment

FinishCheckoutProcess.inc.php

现在的 thankyou.php 利用AJAX来执行 FinishCheckoutProcess.inc.php 异步和 FinishCheckoutProcess.inc.php 有一个PHP。 INI它的设置是这样的:
ignore_user_abort(真正的);

Now thankyou.php makes use of AJAX to execute FinishCheckoutProcess.inc.php asynchronously and FinishCheckoutProcess.inc.php has a PHP.ini setting in it that goes like this: ignore_user_abort(true);

现在AJAX和ignore_user_abort(真)的组合允许支付过程后,没有任何错误,即使用户关闭浏览器窗口中运行,但由于这个脚本无关的用户或我只是想浏览器知道,如果有可能在像独立的应用程序独立于浏览器的一个后台运行该脚本。

Now the combination of AJAX and ignore_user_abort(true) allows the after payment process to run without any errors even if the user closes his browser window, but since this script has nothing to do with the user or the browser I just wanted to know if it is possible to run this script in the background like a standalone application independent of the browser.

另外我的网络服务器是Apache和操作系统就是Linux(Ubuntu的操作系统)。

Also my WebServer is Apache and OS is Linux(Ubuntu OS).

我的工作是越来越做,但我只是想知道,如果有更好/更安全的方式来做到这一点。

My work is getting done but I just want to know if there is a better/safer way to do it.

反正在此先感谢大家,这个网站已经帮助我比任何一本书可以有。因此,所有你的专家那里谁捐出自己的时间给像我这样你们新手是真棒。请保持良好的工作。

Anyway thanks in advance to everyone, this site has helped me more than any book could have. So all you experts out there who donate their times to newbies like me you guys are awesome. Please keep up the good work.

再次感谢了很多。

根据收到的建议
如果我使用EXEC的方法来执行FinishCheckoutProcess.inc.php,将在执行与数据库相关的命令和将它能够运行更多PHP脚本。

Based on suggestions received If I use the "exec" method to execute the FinishCheckoutProcess.inc.php, will this execute database related commands and will it be able to run further PHP scripts.

FinishCheckoutProcess.inc.php 依次执行一系列其他PHP脚本反过来执行其他PHP脚本,所以会使用执行命令运行FinishCheckoutProcess.inc.php创建任何困难。

FinishCheckoutProcess.inc.php in turn executes a series of other PHP scripts which in turn executes other PHP scripts, so will using "exec" command to run FinishCheckoutProcess.inc.php create any difficulties.

FinishCheckoutProcess.inc.php 程序的也与MySQL数据库互动,让我能够做到这一点,如果我使用执行这个脚本 EXEC 命令。我现在正在传递必要的MySQLi连接对象这个PHP脚本。所以,我可以通过它使用同样的方法为 EXEC

FinishCheckoutProcess.inc.php process also does interaction with the MySQL database, so will I be able to do this if I execute this script using "exec" command. I am passing the necessary MySQLi connection object to this PHP script right now. So can I pass it the same way to it using "exec"

同样的过程,因为它会产生使用一组4图像文件相当沉重的 IMagick ImageMagick的

Also the process is quite heavy as it generates a set of 4 image files using IMagick and ImageMagick.

据生成一组有序的每个产品4图像文件,所以如果1产品的数量为10,则产生的将是1x10x4总文件= 40

It generates a set of 4 image files for every product ordered, so if the quantity of 1 product is 10 then the total files generated will be 1x10x4 = 40

如果有两个产品具有一个量作为2,而另一个具有数量为4,则所产生的总的文件将是
1x2x4 = 8 +
1x4x4 = 16 = 24

If there are two products with one having quantity as 2 and the other having quantity as 4 then the total files generated will be 1x2x4 = 8 + 1x4x4 = 16 = 24

所以该脚本可能需要很长一段时间运行,并且不能被允许由于停止超时的原因,需要完成什么它开始

So this script might need to run for a long time and cannot be allowed to be stopped due to time out reasons, it needs to finish what it started.

Basiclly在 FinishCheckoutProcess.inc.php 的逻辑和过程非常复杂,所以只是想,如果确认了 EXEC 可以处理与否。

Basiclly the FinishCheckoutProcess.inc.php logic and process is quite complex so just want to confirm if the "exec" can handle it or not.

另外,我不知道,但他们中的一些还利用$ _SESSION变量,但如果这是一个问题,我可以修改它,$仅_SESSION变量得到的在一个地方使用,并且是在$ _SESSION GET在浏览器中设置前在 FinishCheckoutProcess.inc.php 脚本执行。一些previous PHP脚本。

Also I am not sure but some of them also make use of $_SESSION variables, but if this a problem I can modify it, $_SESSION variables only get's used in one place and yes the $_SESSION get's set in the browser before the FinishCheckoutProcess.inc.php script is executed. By some previous PHP script.

我只是想执行 FinishCheckoutProcess.inc.php 脚本独立于父/调用脚本即 thankyou.php ,这样如果用户关闭浏览器,然后在 FinishCheckoutProcess.inc.php 不会停止或中止becuse父/调用脚本即 thankyou.php 现在不再运行。

I just want to execute the FinishCheckoutProcess.inc.php script independent of the parent/calling script i.e. thankyou.php, so that if the user closes the browser then the FinishCheckoutProcess.inc.php will not stop or abort becuse the parent/calling script i.e. thankyou.php is now no longer running.

推荐答案

据我所知,你正在寻找的东西像Laravel提供与它的照亮/队列套餐:

From what i understand, you are looking for something like Laravel offers with it's illuminate/queue package:

队列让你推迟的时间处理耗时的任务,如发送电子邮件,直到这大大加快了网页请求您的应用程序稍后的时间。

Queues allow you to defer the processing of a time consuming task, such as sending an e-mail, until a later time which drastically speeds up web requests to your application.

这是不是只有Laravel提供,尽管它简化/减轻这种机制的实现。

This isn't something that only Laravel offers, though it does simplify/ease the implementation of such mechanism.

在你有 supervisord 执行工人的PHP脚本,执行你把一个共同的地方任务(DB TABEL,文件系统,任何东西)的背景下,这些任务通常某一类/方法与一些变量的引用发送给它。

In the background you have supervisord executing a "worker" php script that executes tasks you put in a common place (db tabel, filesystem, anything), those tasks are usually references to a certain class/method with some variables to send to it.

以下链接可能会给你一个更好的理解:

The following links might give you a better understanding:

  • http://supervisord.org/index.html
  • https://laravel.com/docs/5.1/queues
  • https://laravel.com/docs/5.1/queues#supervisor-configuration

有很多方法,你可以实现一个排队系统,也没有使用 supervisord 的。但我因为它保证我的任务正在处理中,即使重新启动服务器(如果配置正确)最近实施这个方法我自己。

There are many ways you could implement a queue system, also without the use of supervisord. But i recently implemented this method myself because it guarantees my tasks are being processed, even after server restart (if configured properly).

这篇关于运行PHP脚本就像没有浏览器的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆