Note that there are some explanatory texts on larger screens.

plurals
  1. POdirectory structure for queued jobs (cron jobs) in zend framework
    text
    copied!<p>I found quite a few posts related to directory structure and cron jobs in Zend Framework, and yet no clear answer :(</p> <p>I have the following code to create a job that sends an email. Works perfectly as long as the script (emailNotification.php) is under /jobs in the public directory.</p> <pre><code>public function emailAction() { $request = $this-&gt;getRequest(); if ($request-&gt;isPost()) { $emailFrom = $request-&gt;getPost('emailFrom'); $messageFrom = $request-&gt;getPost('messageFrom'); $subject = $request-&gt;getPost('Sub'); $emailTo = $request-&gt;getPost('emailTo'); // create a queued job date_default_timezone_set('UTC'); $q = new ZendJobQueue(); $ts = date('Y-m-d H:i:s', time()+30); $id=$q-&gt;createHttpJob('jobs/emailNotification.php',array('emailFrom'=&gt;$emailFrom, 'messageFrom'=&gt;$messageFrom,'subject'=&gt;$subject, 'emailTo'=&gt;$emailTo), array('name'=&gt;'email notification using a single job execution scheduled to run after 30 seconds','schedule_time'=&gt;$ts)); if(!$id) $this-&gt;_helper-&gt;json(array('status' =&gt; 'success', 'message' =&gt; "Queued job didn't work.")); $this-&gt;_helper-&gt;json(array('status' =&gt; 'success', 'message' =&gt; "Email sent successfully.")); } // request-&gt;isPost() }// function emailAction </code></pre> <p>My directory structure is the default structure created by ZF:</p> <pre><code> [MyProject] [application] [data] [docs] [library] [public] index.php [scripts] </code></pre> <p>How do I modify createHttpJob to run the script from a different directory, say scripts/jobs instead of public/jobs? Is there anything else I should be doing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload