简体   繁体   English

我可以使用Laravel 4队列在Windows上处理打印作业吗?

[英]Can I use Laravel 4 Queues to process print-jobs on Windows?

This question is a continuation to questions I have asked previously with regard to printing documents via Word on Windows from Laravel. 这个问题是我之前提出的关于通过Laravel的Windows上的Word打印文档的问题的延续。

My issue was that I did not want to launch the necessary printing tasks within a POST request as this would show no feedback of the task, and would only respond once the task completed. 我的问题是我不想在POST请求中启动必要的打印任务,因为这不会显示任务的反馈,并且只会在任务完成后响应。

For example, if I called the POST /pledge/submit route, I would not want to call the necessary tasks for printing within that same request for the route. 例如,如果我调用POST /pledge/submit路由,我不希望在该路由的同一请求中调用必要的打印任务。

Now, I see that Laravel 4 has a facility called Queues , which (I assume) would allow me to background process these tasks, and postpone them until a later time. 现在,我看到Laravel 4有一个名为Queues的工具,(我假设)允许我后台处理这些任务,并将它们推迟到以后的时间。

Having read through the documentation, I see that it supports four different drivers, one of which is sync . 通读了文档,我发现它支持四种不同的驱动程序,其中一种是sync

Question: Can I use this driver to create new print jobs in the queue, and have them executed by an external application (such as one created in Delphi)? 问题:我可以使用此驱动程序在队列中创建新的打印作业,并让它们由外部应用程序(例如在Delphi中创建的应用程序)执行吗? The app would periodically check to see if there are items in the queue, and then execute them (and, of course, remove them). 应用程序会定期检查队列中是否有项目,然后执行它们(当然,删除它们)。

I am simply trying to find the best way to publish documents without the end-user having to wait for the page to respond whilst printing is underway. 我只是试图找到发布文档的最佳方式,而最终用户不必在打印期间等待页面响应。 Further, I am new to queues in PHP, and am not familiar with how they work (in so far as a detailed process flow). 此外,我不熟悉PHP中的队列,并且不熟悉它们的工作方式(就详细的流程而言)。 If someone could also explain this, I would appreciate it very much. 如果有人也可以解释一下,我会非常感激。

The queue system wouldnt work for your Delphi program out of the box - you would need to make some modifications. 队列系统无法为您的Delphi程序提供开箱即用的功能 - 您需要进行一些修改。

Instead - the easiest way would be to make your own 'table' in your database, called 'pending_print_jobs'. 相反 - 最简单的方法是在数据库中创建自己的“表”,称为“pending_print_jobs”。

When the user wants to print job 'x' - you get PHP to save the print job in the 'pending_print_jobs' table with all the details you need (such as file to be printed, the user who did it etc etc). 当用户想要打印作业'x'时 - 您可以使用PHP将打印作业保存在'pending_print_jobs'表中,其中包含您需要的所有详细信息(例如要打印的文件,执行该操作的用户等等)。

Then you would get your external application (ie your Delphi program) to periodically check the 'pending_print_jobs' table in your database. 然后你会得到你的外部应用程序(即你的Delphi程序)来定期检查数据库中的'pending_print_jobs'表。 If it finds any records - it can action them - and print the file. 如果它找到任何记录 - 它可以操作它们 - 并打印文件。

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

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