いろんなところで、同じタイトルで出ていますが、うまくいかないものであったり、疑問があったりしましたので、整理してみました。私なりのやり方です。
- pearのインストール
pear config-create /virtual/自分のユーザ名 .pearrc
pear -c /virtual/自分のユーザ名/.pearrc install -o PEAR
これで、/virtual/自分のユーザー名/pearのところに、pearがインストールされ、その設定が.pearrcに書き込まれます。
-
パスを通す。
vi .bash_profile
export PATH=~/pear/php:~/pear:$PATH
としておきます。
-
symfonyのインストール
普通に
pear channel-discover pear.symfony-project.com
pear install symfony/symfony
- .htaccessへの設定
一部追加します。
Options +FollowSymLinks +ExecCGI
AddHandler application/x-httpd-phpcgi .php
mod_gzip_on Off
-
symfonyコマンドでプロジェクトを作成します
- 最後、WEBフォルダをシンボリックリンクで結びます
ln -s /virtual/自分のユーザ名/プロジェクト名/web/ /virtual/自分のユーザ名/public_html/ドメイン名
ln -s /virtual/自分のユーザ名/pear/data/symfony/web/sf/ /virtual/自分のユーザ名/プロジェクト名/web/sf
以上で、完成です。
いろいろと掲載されてはいましたが、結局うまく行かず、悩んでおりましたが、ようやくできました。
- apps/(appname)/config/view.ymlを以下のようにcontent-typeを変更
1
2
3
| default:
http_metas:
content-type: text/html; charset=Shift_JIS |
- apps/(appname)/config/filters.ymlを以下のように変更
1
2
3
4
5
6
7
8
9
| rendering: ~
web_debug: ~
security: ~
MobileFilter:
class: MobileFilter
cache: ~
common: ~
flash: ~
execution: ~ |
- 最後に、lib/filters/MobileFilter.phpを作成する。
コードはべたべたなので、綺麗に書いてくださいね。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| <?php
class MobileFilter extends sfFilter{
public function execute($filterChain = null){
if ($this->isFirstCall()){
//error
$er=error_reporting();
if ($er > E_STRICT){
error_reporting($er - E_STRICT );
}
require_once ('Net/UserAgent/Mobile.php');
$userAgent=Net_UserAgent_Mobile::singleton();
$this->getContext()->getRequest()->setAttribute('userAgent', $userAgent);
//出力文字コードの制御
// sfConfig::set('sf_charset',"shift_jis");
sfConfig::set('sf_charset',"UTF-8");
$this->encodingParams('SJIS-win','UTF-8');
mb_internal_encoding('UTF-8');
//mb_http_output('SJIS-win');
// ob_start('mb_output_handler');
ob_start( array($this,'m_output_handler'));
}
if ($filterChain) $filterChain->execute();
}
function m_output_handler($buffer){
sfConfig::set('sf_charset',"shift_jis");
error_log($buffer,3,"/var/www/morenavi/log/mobile.log");
return mb_convert_encoding($buffer,'SJIS-win','UTF-8');
//return $buffer;
}
protected function encodingParams($from,$to){
if ($to !='' && $from !='' && $from != $to ){
$params=$this->getContext()->getRequest()->getParameterHolder()->getNames();
foreach ($params as $param){
$in=$this->getContext()->getRequest()->getParameter($param);
$this->getContext()->getRequest()->setParameter($param, mb_convert_encoding($in,$to,$from));
}
}
}
} |
dwPrototypeWindowPluginでエラーが発生した。どうやら、prototype1.5.1からprototype.Browserというものがあるらしい。で困ったところ、Prototype.BrowserFeaturesにすればよいみたい。
Prototype.Browser ⇒ Prototype.BrowserFeatures
これでエラーが出なくなりました。
ところが、それでもうまくいきません….。
(もしかしたら、下記のsfPrototypePluginを入れたらよかったのかもしれません)
というところで、sfModalBoxPluginを発見。実は、これは便利!
インストールは、
$ symfony plugin-install http:⁄⁄plugins.symfony-project.com/sfPrototypePlugin
$ symfony plugin-install http:⁄⁄plugins.symfony-project.com/sfModalBoxPlugin
templateにて、
<?php use_helper('ModalBox') ?>
<?php echo m_link_to('モーダル', 'module/action') ?>
でいけてしまいました。