LoginSignup
41
32

More than 5 years have passed since last update.

PHPの設定をコマンドラインで確認する

Posted at

実行環境構築中などで頻繁に叩くコマンドをピックアップしてみました。
php -r 'phpinfo();'なんてする必要はありません。

-v バージョンの表示

phpのバージョン表示

PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies

-i PHPインフォメーション

phpinfo()の出力をしてくれます。全情報が出てくるので出力が大きくて使いづらいかも。出力のサンプルも省略します

-m モジュールのリスト表示

非常によく使います。出来上がったphpアプリがエラー吐くのは大体エクステンションが足りてないパターンなんで。

[PHP Modules]
calendar
Core
:
(略)
:
yaml
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

--ini コンフィグファイルの表示

読み込んだコンフィグファイルを全部出力します

Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File:         /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed:      /etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/15-xml.ini,
:
(略)
:

--ri extension名

各機能ごとに設定の詳細を出力します。設定値まで出てくれるのでこれもよく使います。


Core

PHP Version => 7.0.13-0ubuntu0.16.04.1

Directive => Local Value => Master Value
highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
display_errors => Off => Off
display_startup_errors => Off => Off
enable_dl => Off => Off
expose_php => On => On
docref_root => no value => no value
docref_ext => no value => no value
html_errors => Off => Off
:
(略)
:
exit_on_timeout => Off => Off
error_reporting => 22527 => 22527
zend.assertions => -1 => -1
zend.enable_gc => On => On
zend.multibyte => Off => Off
zend.script_encoding => no value => no value
zend.detect_unicode => On => On

最後に

この記事書いてて--iniの存在に気が付きました。たまにはヘルプも読みなおすのもいいですね。

41
32
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
41
32