http://twitter.com/#!/dhofstet/status/25072465570963456
Googleで検索するだけの時代でないことをひしひしと感じます。
自分で検索してたらずいぶんと時間がかかっていたと思います。
というわけでこちら。鬼才mcurryのアプリケーション内にそのコードがありました。
https://github.com/mcurry/20Couch/blob/master/app/controllers/update_controller.php
まず、下記で最新バージョン番号を取ってきます。
//get the current version
App::import('Core', 'HttpSocket');
$Http = new HttpSocket();
$latestVersion = trim($Http->get(Configure::read('20Couch.home') . '/latest'));
下記で取得後、ファイルが正しくダウンロードできたか確認しています。
$Http = new HttpSocket();
$Setting = ClassRegistry::init('Setting');
$url = sprintf('%s/registrations/direct/%s/' . Configure::read('Update.file'), $home, $Setting->find('value', 'registration_key'));
$latest = $Http->get($url);
展開処理
$msg = '(using ZipArchive)';
$zip = new ZipArchive;
$zip->open(TMP . Configure::read('Update.file'));
$result = $zip->extractTo(ROOT);