ユーザ用ツール

サイト用ツール


cakephp:1.3x_pear

1.3x で pear

  • CakePHP 1.3系 でPearを使う
    /app/config/bootstrap.php に
App::build(array('pears' => array('/usr/share/php')), true);

Pear を使用するところに

App::import('pear', 'TagCloud', array('file' => 'HTML/TagCloud.php'));
 bootstrap.php
       App::build(array('pears' => array('/usr/share/pear')), true);
 対象cntoroller その1
       App::import('pear', 'Log', array('file' => 'Log.php'));
       $log = Log::factory('file', '/var/www/vhosts/mlb/cake/api.mlb.jp/tmp/logs/log.txt', 'ident');
       $log->log(serialize($this->params['form']), PEAR_LOG_INFO);
 対象cntoroller その2
   public function index() {
       $this->customLog('custom.log', $this->params['form'], 'tag');
   }
   
   public function customLog($filename, $param, $ident) {
       App::import('pear', 'Log', array('file' => 'Log.php'));
   /*
       $param   = serialize($param);
       $handler = 'file';
       $name    = LOGS . $filename;
       $ident   = $ident;
       $conf    = array('mode'=>0644,'timeFormat'=>'%Y/%m/%d %H:%M:%S');
       $level   = PEAR_LOG_INFO;
       $log = Log::singleton($handler, $name, $ident, $conf, $level);
   */
       $log = Log::singleton('file', LOGS . $filename, $ident,
                             array('timeFormat'=>'%Y/%m/%d %H:%M:%S'));
       $log->log(serialize($param));
   }
cakephp/1.3x_pear.txt · 最終更新: 2014/02/26 07:13 by clownclown

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki