简体   繁体   English

PHP - 包含或标题

[英]PHP - Include or Header

I need some advice on the best way to set up a process that I am running which runs a series of scripts that run one after the other and will potentially be a cron job. 我需要一些关于设置我正在运行的进程的最佳方法的建议,该进程运行一系列脚本,这些脚本一个接一个地运行,并且可能是一个cron作业。 Each one can be run on its own but depends on the previous job having run successfully for it to work. 每个人都可以自己运行,但取决于之前的工作是否已成功运行。 My sequence is as follows: 我的顺序如下:

  1. Set variables for the jobs. 设置作业的变量。
  2. Extract a csv file from an email when it arrives. 到达时从电子邮件中提取csv文件。
  3. Parse that csv file into the database 将csv文件解析到数据库中
  4. Generate a series of PDF files based on the database with the new data and 1 above. 使用新数据和上面的1生成基于数据库的一系列PDF文件。
  5. Email those PDFs to the required recipients. 将这些PDF通过电子邮件发送给所需的收件人

Given the above I cannot do any step until the previous one is complete. 鉴于上述情况,我不能做任何步骤,直到前一个完成。

Each step is its own php script. 每一步都是自己的PHP脚本。

What I'd like advice on is what the best method to set this up is. 我想建议的是设置它的最佳方法是什么。

At the moment I have a single page with all the above as include statements in one page. 目前,我在一个页面中有一个包含所有上述内容的包含语句的页面。

Each one runs and then the next runs etc. 每个运行然后下一个运行等。

I'm not sure if this fairly long script is the best way or whether I should actually use a Header statement to make each one run and then return to my main action page with some variables confirming the previous script has run. 我不确定这个相当长的脚本是否是最好的方法,或者我是否应该使用Header语句使每个运行,然后返回到我的主操作页面,其中一些变量确认前一个脚本已运行。

Does it make any difference? 它有什么不同吗?

如果你使用require更好,因为如果没有得到文件但是包含没有,则需要抛出错误。

在db中创建一个检查点,当一个作业完成时将其设置为“0”

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

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