久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Cron 調度器 CakePHP 2.0

Cron Dispatcher CakePHP 2.0(Cron 調度器 CakePHP 2.0)
本文介紹了Cron 調度器 CakePHP 2.0的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 CakePHP 2.0 并且一直在嘗試設置一個 cronjob 以在控制器中執行一個方法.我一直在發瘋,查看各種教程和隨機網站,看看我是否能找到解決方案.

I am using CakePHP 2.0 and have been trying to setup a cronjob to execute a method in a controller. I've been going nuts, looking over various tutorials and random sites to see if I could find a solution.

我收到的錯誤是:

Undefined variable: argc [APP/webroot/cron_dispatcher.php, line 83

這是我的 app/webroot/ 目錄中 cron_dispatcher.php 文件的底部.

Here is the bottom of the cron_dispatcher.php file in my app/webroot/ directory.

if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
        trigger_error("CakePHP core could not be found.  Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php.  It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
    }
    if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
    return;
    } else {
      define('CRON_DISPATCHER',true);
    if($argc >= 2) {
        $Dispatcher= new Dispatcher();
        $Dispatcher->dispatch($argv[1]);
        }
    }

我找不到這些變量($argv 和 $argc)的定義位置.它們沒有在 dispatcher.php 文件本身的任何地方定義.我搜索了谷歌無濟于事.我不是 100% 確定 Dispatcher 是如何工作的,但任何幫助將不勝感激.謝謝.

I cannot find where these variables ($argv and $argc) are defined. They aren't defined anywhere in the dispatcher.php file itself. I searched Google to no avail. I'm not 100% sure how the Dispatcher works, but any help would be greatly appreciated. Thanks.

== 更新GoDaddy 的共享主機不允許您更改 argc argv 的設置.

== UPDATE GoDaddy's shared hosting doesn't allow you to change the settings of argc argv.

推薦答案

如果其他人有興趣,

在新的 CakePHP 2.0.5 中,您將在 webroot 文件夾中創建一個 index.php:

In the new CakePHP 2.0.5, you will an index.php in webroot folder:

復制這個文件,命名為cron_dispatcher.php,放到同一個目錄下(webroot)

Copy this file and name it cron_dispatcher.php, and place it into the same directory (webroot)

您會在最底部找到此代碼:

You will find this code at the very bottom:

$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));

將底部改為

define('CRON_DISPATCHER',true);
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest($argv[1]), new CakeResponse(array('charset' => Configure::read('App.encoding'))));

您在這里做了兩件事:將 CRON_DISPATCHER 設置為 true,并傳遞環境變量 ($argv[1]).

You're doing two things here: Setting CRON_DISPATCHER to true, and passing environment variables ($argv[1]).

在你的控制器中,在你做任何其他事情之前添加這一行:

In your controller, add this line before you do anything else:

if (!defined('CRON_DISPATCHER')) { $this->redirect('/'); exit(); }

這將確保訪問 yoursite.com/controller/cronaction 的人將無法運行您的腳本.

This will ensure people going to yoursite.com/controller/cronaction won't be able to run your script.

在 webroot 中的 htaccess 文件中,添加:

In your htaccess file in webroot, add this:

<Files  "cron_dispatcher.php">
    Order deny,allow
    Deny from all
</Files>

這將確保訪問 yoursite.com/cron_dispatcher.php 的人無法運行它.

This will ensure poeple going to yoursite.com/cron_dispatcher.php won't be able teo run it.

現在使用以下命令設置 cron 作業:

Now set up the cron job using something like the command:

php /home/yoursite/public_html/cakephp/app/webroot/cron_dispatcher.php /controller/cronjobaction

這篇關于Cron 調度器 CakePHP 2.0的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 最新中文字幕在线播放 | 欧美a在线 | 国精产品一区一区三区免费完 | 日韩免费视频一区二区 | 国产精品999 | 久久久国产精品视频 | 午夜影院在线免费观看视频 | 久草在线中文888 | 91在线观看免费 | 亚洲精品视频在线播放 | 美女爽到呻吟久久久久 | 成人av电影免费在线观看 | 二区成人 | 在线亚洲一区 | 国产成人精品午夜 | 91精品中文字幕一区二区三区 | 精品色| 日韩中文字幕在线观看视频 | 久久精品国产99国产精品 | 国产美女精品 | 亚洲视频欧美视频 | 国产伦精品一区二区三区四区视频 | 国产精品a一区二区三区网址 | 99精品九九 | 九九热免费观看 | 91不卡| 九九热精品在线 | 国产精品99999 | 涩爱av一区二区三区 | 日本成人中文字幕在线观看 | 毛片在线免费 | 亚洲精品一区在线观看 | 五月天婷婷综合 | 欧美日韩精品一区 | 中文二区 | 婷婷福利 | 中文字幕在线免费视频 | 国产精品视频免费观看 | 7777在线视频 | 日韩av.com| 国产精品久久久久久久久免费桃花 |