LoginSignup
0
0

More than 3 years have passed since last update.

PHPのerror_log関数を使用しての仮想環境vagrantへのpath

Posted at

自分用忘備録
var_dump等で値を確認できない時。
仮想環境vagrant上で開発時にデスクトップ上にerror_logファイルを作成しようとしたが、仮想環境のpathが違い少しハマった。

経緯

画面がエラーで表示されず、値を返さない裏側の処理があり、
デバッグで変数情報をファイル出力するerror_log関数で追っていくことにした。

開いているディレクトリは権限があり、
error_log(print_r($Data,true),"3","/vagrant/system/debug.log");

$Data = 値を確認したい変数をセット
/vagrant/system/ = vagrant上のpath(ディレクトリsystem以下にファイルが作成される)
debug.log = 新規ファイル名(なんでも構わない)

ファイルが作成された後は同じファイル名で再度叩くと同ファイルに値の内容が上書きされる。

vagranのpath確認コマンド

$vagrant up
↓
$vagrant ssh(vagrantへログイン)
↓
[vagrant@localhost ~] $cd /vagrant/
 複数のファイルorディレクトリ名    system/
↓
[vagrant@localhost ~]$cd /vagrant/system/
↓
[vagrant@localhost system]$pwd
/vagrant/system
↓
[vagrant@localhost system]$ls (念の為systemディレクトリ内ファイル確認)

問題なさそうなら、値を調べたい箇所に以下error_log関数を記述。
error_log(print_r($Data,true),"3","/vagrant/system/新規ファイル名");

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0