ラベル PHP の投稿を表示しています。 すべての投稿を表示
ラベル PHP の投稿を表示しています。 すべての投稿を表示

2012年6月27日水曜日

xdebugでwarningがでる。

xdebugが有効かどうか確認すると下記のようなwarningがでる。

[root@hoge ~]# php -i | grep -i "xdebug support"
PHP Warning:  Xdebug MUST be loaded as a Zend extension in Unknown on line 0
xdebug support => enabled
[root@hoge ~]# 
■/etc/php.ini
extension=xdebug.so
   ↓ コメントアウト
;extension=xdebug.so

■/etc/php.d/xdebug.ini
zend_extension=/usr/lib/php/modules/xdebug.so
xdebug.remote_enable=On
xdebug.remote_connect_back=On
xdebug.remote_autostart=On
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.collect_params=On
xdebug.dump.GET=*
xdebug.dump.POST=*

extensionをzend_extensionに変更し、リモートの設定を追加した。(リモートデバッグを行うため) また、xdebug.remote_connect_back=On を設定して複数のクライアントからリモートデバッグが実行できるようにした。

「xdebug.remote_connect_back」は。xdebug 2.1以降で利用できる。

apacheを再起動して設定が有効になったか確認する
[root@hoge ~]# php -i | grep xdebug
/etc/php.d/xdebug.ini,
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
 ・
 ・
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => On => On
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
 ・
 ・
 ・

2011年7月26日火曜日

PHP5.3 タイムゾーン エラー?

ディスクがクラッシュして再インストールしているが、CAKEPHP(1.3.10)を実行しようとすると下記のエラーが発生。

Warning (2): strtotime() [http://php.net/function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead [CORE/cake/libs/cache.php, line 597]

Notice: Trying to get property of non-object in /var/www/html/cakephp/cake/libs/cache/file.php on line 248 Fatal error: Call to a member function cd() on a non-object in /var/www/html/cakephp/cake/libs/cache/file.php on line 248 
今回は PHP5.3 をインストールしてしたが、PHPの設定タイムゾーンの設定が必要なようだ。(いつの間に r(?_?);)
変更前 PHP.ini
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
変更後 PHP.ini
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Tokyo

2011年4月13日水曜日

CakePHP つまずき

久々に Cakephp をさわったら、「Warning (512): Could not find validation handler ... 」と Warning が多発。

良く確認したら、CakePHPを複数アプリを起動できるようにしていたので、起動方法(URL)が間違っていたためであった。しかし、久々に操作だったので事をすっかり忘れてしまって解決に思わぬ程時間がかかってしまった。 (_ _ ;)尸 マイリマシタ…

vhost.conf で起動アプリを制御する。

CakePHPで複数アプリを起動させるため、httpd の vhost.conf でバーチャルホストを定義して起動するアプリごとに起動するパスを分けることで、アプリのベースパス(URL)を制御する。

2011年1月9日日曜日

Mantis 日付(年)の選択範囲を変更

Mantisで昨年の案件を追加しようとしたら、追加した日付のカスタム項目の年が 2011 ~ 2015 と表示され昨年(2010)が表示されないため選択できない。(日付はセレクトボックスで年・月・日が表示される)

昨年も同様の現象があったように思うが、昨年はセレクトボックス表示を解除して対応したのかもしれないが、今年は昨年から表示されるように改良することにした。

修正前は、2011年から2015年が表示される。
2010年を指定したいのだが表示されないので指定できない。

修正後は、2010年から2014年が表示されるよになり、2010年を指定することが可能になった。
めでたし、めでたし。(^^ゞ

修正するプログラムは、core フォルダの中の date_api.php です。(coreの中を修正するとバージョンアップの時に再度修正が必要かも)
下記に修正箇所を記載します。
date_api.php の中の print_year_range_option_list関数の先頭を修正します。
修正前 → $t_current = date( "Y" );
修正後 → $t_current = date( "Y" ) - 1;

  function print_year_range_option_list( $p_year = 0, $p_start = 0, $p_end = 0) {
    $t_current = date( "Y" ) - 1; /* 2011.01.08 */
    $t_forward_years = config_get( 'forward_year_count' ) ;

    $t_start_year = $p_start ;
    if ($t_start_year == 0) {
      $t_start_year = $t_current ;
    }
    if ( ( $p_year < $t_start_year ) && ( $p_year != 0 ) ) {
      $t_start_year = $p_year ;
    }

    $t_end_year = $p_end ;
    if ($t_end_year == 0) {
      $t_end_year = $t_current + $t_forward_years ;
    }
    if ($p_year > $t_end_year) {
      $t_end_year = $p_year + $t_forward_years ;
    }

    for ($i=$t_start_year; $i <= $t_end_year; $i++) {
      if ($i == $p_year) {
        PRINT "" ;
      } else {
        PRINT "" ;
      }
    }
  }

2010年11月21日日曜日

CakePHPディレクト構成の変更

When the archive is extracted, it becomes a composition of the following directories.

  1. Method of arranging directory that needs manager authority.
  2. ├var
    │
    ├www
    │ │ ├cake ← When the archive is extracted,
    │ │ │ ├app
    │ │ │ │ ├config
    │ │ │ │ ├controllers
    │ │ │ │ ├models
    │ │ │ │ ├plugins
    │ │ │ │ ├tmp
    │ │ │ │ ├vendors
    │ │ │ │ ├views
    │ │ │ │ ├webroot ← It is set to the document route.
    │ │ │ │ ├.htaccess
    │ │ │ │ └index.php
    │ │ │ ├cake
    │ │ │ ├vendors
    │ │ │ ├.htaccess
    │ │ │ └index.php

  3. Method of arranging directory that doesn't need manager authority.
  4. ├cake
    │ ├app ・・・(1)
    │ │ ├config
    │ │ ├controllers
    │ │ ├models
    │ │ ├plugins
    │ │ ├tmp
    │ │ ├vendors
    │ │ ├views
    │ │ ├webroot ・・・(3)
    │ │ ├.htaccess
    │ │ └index.php
    │ ├cake ・・・(2)
    │ ├vendors
    │ ├.htaccess
    │ └index.php

    It becomes the following if it arranges it according to the custom of the Linux system.

    │
    ├ home
    │ └ user
    │   └ app ← Directory (1) is moved here.
    ├ usr
    │ └ lib
    │   └ cake ← Directory (2) is moved here.
    ├ var
    │ └ www
    │   └ *** ← Contents of the directory that name is (3) are moved here.


    The procedure summary.
    unzip ./cakephp-cakephp-1.3.5-0-ga16f4c5.zip
    $ mv ./cakephp-cakephp-fd82f1b/app /home/user/app
    $ mv ./cakephp-cakephp-fd82f1b/cake /usr/lib/cake
    $ mv ./cakephp-cakephp-fd82f1b/app/webroot/* /var/www
    $ mv ./cakephp-cakephp-fd82f1b/app/webroot/.htaccess /var/www
    $ chmod -R 0777 /home/user/app/tmp
    When the movement of the file is completed, three places of the following of the content of index.php are edited.

    • ROOT定数にappを含むディレクトリへのパスを設定する。

    • 今回の例では、"/home/user"
    • APP_DIR定数にappディレクトリの名前を設定する。

    • 今回の例では、"app"
    • CAKE_CORE_INCLUDE_PATH定数にcakeディレクトリを含むディレクトリへのパスを設定する。

    • 今回の例では、"/usr/lib"

    Concretely, it edits it as follows.

    if (!defined('ROOT')) {
       define('ROOT', DS . "home" . DS . "user");
    }
    if (!defined('APP_DIR')) {
       define('APP_DIR', "app");
    }
    if (!defined('CAKE_CORE_INCLUDE_PATH')) {
       define('CAKE_CORE_INCLUDE_PATH', DS . "usr" . DS . "lib");
    }

2010年9月1日水曜日

PHPからOracleへの接続

CentOSにPHPのOCI8とPDO_OCIとOracle11gをインストールした時からログに下記の2つが出力されていた。
  • 「PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/oci8.so' - libclnsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0」
  • 「PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_oci.so' - libclnsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0」
 とりあえず、PHPからOracleへ接続しないので放置しておいたが、今回Firefoxがやたら落ちるのでログを確認していたら気になるので対処することにしました。

 このエラーは、ダイナミックリンクライブラリである oci8.so や pco_oci から libclnsh.so.11.1 が参照できないことを告げています。 よって、ダイナミックリンクライブラリが参照できるように、LD_LIBRARY_PATHに追加すればよいことになります。
(手順)
  • libclnsh.so.11.1のディレクトリを確認する。
  • /etc/ld.so.conf.dに上記のパスを記載したファイル(oracle11g.conf)を作成する。
    (oracle11g.confの記載内容:/usr/oracle/app/product/11.1.0/db_1/lib)
  • ldconfigを実行してld.so.cacheを再構築します。
  • httpdを再起動してログを確認します。
以上で、やっと余計なログが解消されました。(笑)