PHP
Symfony

Symfony2でintlとapc

More than 3 years have passed since last update.

ざっと開発環境構築でハマった


環境

centos6.4

php5.5.13(remiレポジトリからインストール)


症状

公式ぽい手順でcomposer使ってSymfony2プロジェクトをインストール、環境チェックしたところ、以下の感じでWARNINGとか言い出しので解決する。xdebugは/etc/php.d/xdebug.ini弄ってすぐだったので省略。

apcもintlも本体に同梱されてるらしいけどyumでインストール時に公式に載ってるオプション指定どうするのかよくわからず。

$ php app/check.php

********************************
* *
* Symfony requirements check *
* *
********************************

* Configuration file used by PHP: /etc/php.ini

** ATTENTION **
* The PHP CLI can use a different php.ini file
* than the one used with your web server.
* To be on the safe side, please also launch the requirements check
* from your web server using the web/config.php script.

** Mandatory requirements **

OK PHP version must be at least 5.3.3 (5.5.13 installed)
OK PHP version must not be 5.3.16 as Symfony won't work properly with it
OK Vendor libraries must be installed
OK app/cache/ or var/cache/ directory must be writable
OK app/logs/ or var/logs/ directory must be writable
OK date.timezone setting must be set
OK Configured default timezone "Asia/Tokyo" must be supported by your installation of PHP
OK json_encode() must be available
OK session_start() must be available
OK ctype_alpha() must be available
OK token_get_all() must be available
OK simplexml_import_dom() must be available
OK detect_unicode must be disabled in php.ini
OK xdebug.show_exception_trace must be disabled in php.ini
OK xdebug.scream must be disabled in php.ini
OK PCRE extension must be available

** Optional recommendations **

OK xdebug.max_nesting_level should be above 100 in php.ini
OK Requirements file should be up-to-date
OK You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions
OK When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156
OK You should not use PHP 5.4.0 due to the PHP bug #61453
OK When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)
OK You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909
OK PCRE extension should be at least version 8.0 (8.34 installed)
OK PHP-XML module should be installed
OK mb_strlen() should be available
OK iconv() should be available
OK utf8_decode() should be available
OK posix_isatty() should be available
WARNING intl extension should be available
Install and enable the intl extension (used for validators).

WARNING a PHP accelerator should be installed
Install and enable a PHP accelerator like APC (highly recommended).

OK short_open_tag should be disabled in php.ini
OK magic_quotes_gpc should be disabled in php.ini
OK register_globals should be disabled in php.ini
OK session.auto_start should be disabled in php.ini
OK PDO should be installed
OK PDO should have some drivers installed (currently available: mysql, pgsql, sqlite)

つかapp/check.php便利過ぎて半笑


apc

yumでリポジトリ指定

$ sudo yum install --enablerepo=remi-php55 php-pecl-apc


intl

libicu*は多分必要だと思うので入れとく

$ sudo yum list installed | grep icu

libicu.x86_64 4.2.1-9.1.el6_2 @base
libicu-devel.x86_64 4.2.1-9.1.el6_2 @base
libicu-doc.noarch 4.2.1-9.1.el6_2 @base

peclでインストール

$ sudo pecl install intl

設定追加


/etc/php.d/intl.ini

extension=intl.so


おkぽくなった


結果

$ php -i | grep "apc\|intl"

Additional .ini files parsed => /etc/php.d/apcu.ini,
/etc/php.d/intl.ini,
apc
apcu
MMAP File Mask => /tmp/apc.XXXXXX
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => /tmp/apc.XXXXXX => /tmp/apc.XXXXXX
apc.preload_path => no value => no value
apc.rfc1867 => Off => Off
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => On => On
apc.smart => 0 => 0
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.writable => /tmp => /tmp
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0