PHP提交通知后15分钟自动发送通知

I would like to know about sending notification to users without using cronjob.

  • Here's the Scenario
    Once userA has submitted the form to pick him/her up, notify (email or change database status into "Pending" and alert in web panel or some sort of notification) Admin if there is nobody reply to pickup that userA in 15min.

Is there any tools to use in PHP or any libraries or scripts? What would solve this situation ?

Thanks in advance for your help :) Sorry if my English is bad :(

You should set up cron job for this. You can compare time difference in minutes and then as per the criteria send the email or update the database.

You can run PHP script. You will have to do so via the CLI interface though.

#!/usr/bin/env php
<?php
# This file would be say, '/usr/local/bin/run.php'
// code
echo "this was run from CRON"

Then, add an entry to the crontab:

* * * * * /usr/bin/php -f /usr/local/bin/run.php &> /dev/null

If the run.php script had executable permissions, it could be listed directly in the crontab, without the /usr/bin/php part as well. The 'env php' part in the script would find the appropriate program to actually run the PHP code. So for the 'executable' version add executable permission to the file:

chmod +x /usr/local/bin/run.php

and then add the following entry into crontab:

* * * * * /usr/local/bin/run.php &> /dev/null

In laravel, you can add jobs to queue. Also you can delay a job by certain time. So every time you receive a new request, you can add a job NotifyAdminIfNoStatusChangeJob to the queue, like so

public function sendNotificationEmail(...)
    {
        //...

        $job = (new NotifyAdminIfNoStatusChangeJob($user))->delay(900);

        $this->dispatch($job);
    }

So what you can do in the job is check the status and notify admin. Note, the job will be executed after 15 minutes, it'll do as needed.

Check delayed queues here : http://laravel.com/docs/5.1/queues#delayed-jobs