smartyの設定 include?path以下の設定がわからない

このQ&Aのポイント
  • smartyの設定について困っています。include_pathの設定がうまくいかず、エラーが出てしまいます。
  • php.iniファイルを変更しても表示が変わらず悩んでいます。また、Smarty.class.phpの指定方法についても不安です。
  • smartyがなくてもアプリケーション開発に影響はないか心配です。個人で趣味の範囲で作成しています。
回答を見る
  • ベストアンサー

smartyの設定 include?path以下の設定がわからない

独学でPHPを学んでいます。 PHPの基本はひととおり理解はできました。 開発環境・最新のXAMPP導入。 windows、OSはVISTA smartyをインストールしましたが、その設定につまずいています。 Smarty.class.phpが存在するパス(D:\xampp\libs)をphp.iniファイル447行目を下記のように設定しましたが、うまくいきません include_path=D:\xampp\libs\ xamppフォルダの下にlibsフォルダを入れたので上のパス指定で問題ないと思うのですが、どこが間違っているのでしょうか。 ちなみに、libs以下の\も不要だろうと思い、消したりして試してみましたが、結果は同じ。下記のように表示がなされます。 Warning: require_once(local/xampp/libs/Smarty.class.php) [function.require-once]: failed to open stream: No such file or directory in D:\xampp\htdocs\lesson\smarty1.php on line 3 Fatal error: require_once() [function.require]: Failed opening required 'local/xampp/libs/Smarty.class.php' (include_path='.;D:\xampp\php\pear\') in D:\xampp\htdocs\lesson\smarty1.php on line 3 上の文章ですが、3行目後半”Smarty.class.php' (include_path='.;D:\xampp\php\pear\')”の部分ですが、php.iniからinclude_pathを変更したりしているのですが、一向に表示が変わりません。 もしかしたらphp.iniファイルは二つあったりするのでしょうか。 php.iniのファイルはPHPフォルダに入っているものでよろしいですよね? もちろんアパッチは再起動させています。 なのにできません・ あと、ロジックファイルの require _once()の()内はSmarty.class.phpだけでもよろしいのでしょうか。 もう悩みすぎて頭がおかしくなりそうですね。 ちなみにsmartyがなくても、アプリケーション開発に支障はありませんでしょうか。 あくまで個人で趣味の範囲でアプリケーションを作成したいと感じています。

  • --w--
  • お礼率29% (35/117)
  • PHP
  • 回答数1
  • ありがとう数1

質問者が選んだベストアンサー

  • ベストアンサー
noname#94983
noname#94983
回答No.1

>php.iniのファイルはPHPフォルダに入っているものでよろしいですよね? ああ、たぶんこれだ。 XAMPPの場合、php.iniは、xampp/apache/bin/php.iniが実際に使われているファイル。こっちを書き換えないといけない。 それと気になったんだが、 (include_path='.;D:\xampp\php\pear\') こうメッセージに出ているって事は、PEARのパスがinclude_pathに設定済みってことになる。だから、include_path='D:\xampp\libs'では問題が起こる。include_path='.;D:\xampp\php\pear\;D:\xampp\libs'としないとまずいだろう。

--w--
質問者

お礼

できました!! 毎度アドバイスありがとうございました! 感謝感謝!

関連するQ&A

  • smartyのdifineについて

    表示するファイルにdefineにてパスを設定すると正常に 表示されるのですが管理が面倒なので別のファイルに defineにてパスを設定するとエラーになってしまいます。 具体的には以下のソースです。 ---Smarty/libs/path.php--- define ('SMARTY_LIBS_DIR', 'C:/Program Files/xampp/htdocs/Smarty/libs/'); ---Smarty/libs/MySmarty.class.php--- require_once dirname(__FILE__) . '/Smarty.class.php'; require_once dirname(__FILE__) . '/path.php'; ---Smarty/index.php--- require_once SMARTY_LIBS_DIR . 'MySmarty.class.php'; 調べてみたのですが表示するファイルに指定する方法しか みつからなかったのですが別ファイルから指定する事は 無理なのでしょうか?

    • 締切済み
    • PHP
  • さくらにsmartyをセットアップする

    http://www.mogutan-blog.com/?eid=283 さくらサーバーと格闘しています。 上記ブログやその他ブログを見ながらパスは通りましたが、やりたい方法とちがうので改めてこちらでお聞きします。 私の方法 1.smartyをwww以下にアップ 2.アップしたフォルダをlibsと改名 3.index.phpでrequire_once '../libs/smarty/Smarty.class.php'; としてokでした。 しかし、php.iniを使って、 require_once './Smarty.class.php'; とパスを編集するには、php.iniをどのように書けばよろしいでしょうか? 現在は、include_path=".:/home/アカウント名/libs/" としており、どのように書けばパスが通るでしょうか? ちなみに簡略フォルダー展開ですが、 ルート ├ libs(smarty)- Smarty - Smarty.class.php ├ php.ini ├ www ┬ index.php     

    • ベストアンサー
    • PHP
  • include_pathについて

    php.ini内のinclude_pathをinclude_path=".;C:\php\include"と設定してC:\windows\(不安なのでC:\php\にも)に置いているのですが、 なぜかphpinfo()を開いて確認すると".;C:\php5\pear"となっています。 Loaded Configuration File を見ても C:\Windows\php.ini となっていますし。 require_once "DB.php"を実行したときに以下のエラーが出たので、 db.phpのインストールも済んでいることから、include_pathが正しく設定されていないのが問題だと思うのですが・・・ Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\users.php on line 2 Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.;C:\php5\pear') in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\users.php on line 2 php.ini以外にも設定しなければいけない個所があるのでしょうか?

    • 締切済み
    • PHP
  • include_path の設定について

    趣味でpearのNet_UserAgent_Mobileライブラリを使用して携帯サイトを作成しておりますが、その各ライブラリファイルで require_once 'Net/UserAgent/Mobile/*****.php'; のようなコードがあるのでそれを変更したくないのと色々な場所からライブラリを使用するのでその都度相対パスを設定したくないので.htaccessでパスの設定をしたいのですが include_pathを設定するとPEAR.phpのパスが設定されてしまいます。その為 require_once 'PEAR.php'; のところでエラーが出ます。 include_pathはあくまでPEAR.phpのパスの設定しか出来ないのでしょうか。 【ライブラリファイルのおいてある場所】 /home/*****/public_html/mobile/Net/UserAgent/Mobile/ 【.htaccess設定】 php_value include_path ".:/home/*****/public_html/mobile/

    • ベストアンサー
    • PHP
  • Smartyのtemplatesとtemplates_cのパスの基準について

    Windows環境でSmartyを動かしています。 動かしているサンプルソースがWindows用ではないため、パスなどを動くように直していたのですが、パスの設定でつまってしまいました。 サンプルのphpファイルはC:\xampp\htdocs\sample\に置いており、 Apacheのinclude_pathにC:\xampp\php\smarty\libs\を設定しました。 「templates_c」「templates」「configs」「cache」のフォルダを同じ場所に作成し、 それぞれディレクトリを指定しようとしたのですが、サンプルの「/home/~」というのをどのように直せばいいのか色々と試していて、 $smarty->template_dir = '../templates/'; $smarty->compile_dir = 'C:/xampp/php/smarty/templates_c/'; $smarty->config_dir = 'C:/xampp/php/smarty/configs/'; $smarty->cache_dir = 'C:/xampp/php/smarty/cache/'; で正常に動くのですが、 $smarty->template_dir = '../templates/'; $smarty->compile_dir = '../templates_c/'; とすると、templates_cが存在しないというエラーが出てきます。 compile_dirを"../"にするとhtdocsの直下にファイルができていたので、compile_dirはphpファイルからの相対パスで、template_dirはlibsからの相対パスになっているように思いますが、相対パスで指定する場合の基準パスが違うのでしょうか?

    • 締切済み
    • PHP
  • PEAR include_pathについて

    はじめまして。色々と調べてみたのですが解決できずにいます。誰か助けて頂けると助かります。学校の部活で「PEARのXML_RSSでRSSを取得してみよ」という課題が出ました。私の家では全てのPCがマックなのでMAMPをつかって以下のような環境でやっています。そこで http://o-ume8.com/junsdiary2/archives/2006/08/20060806_1726.phpを参考に課題に取りかかろうとして試しにPEAR_Infoを試してみたのですが Warning: require_once(PEAR/Info.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/pear_info.php on line 2 Fatal error: require_once() [function.require]: Failed opening required 'PEAR/Info.php' (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/pear_info.php on line 2 の様なエラーが出てしまいます。 pathが通ってないのでしょうか? それとターミナルでphp -v と打つともとのOSの4.4.4と出ます。 phpinfoではちゃんと5.2.0と出ます。 ご教授お願いいたします。 =====環境==== MAMP 1.5 beta 1 PPC os osx 10.4.8 Apache/2.0.59 php 5.2.0 <php.ini> include_path = ".:/Applications/MAMP/bin/php5/lib/php"

    • 締切済み
    • PHP
  • さくらレンタルサーバでのsmartyの設定

    プログラム初心者なのですが、以下教えて頂けないでしょうか。 さくらレンタル(スタンダード)にsmartyを設置を試みているのですが、エラーメッセージが出てしまいます。 環境:PHP 5.2.6 / Smarty 2.6.19 /home/(アカウント)/www/libs/smartyの直下にSmarty.class.php以下、公式サイトからダウンロードしたものをそのままアップし、/home/アカウント/www/smartytest/helloの直下に以下のファイルをアップしました。 (index.php) <?php define('SMARTY_DIR','/home/アカウント/www/libs/smarty/'); define('SMARTY_TEST','/home/アカウント/www/smartysample/hello/'); require_once(SMARTY_DIR.'Smarty.class.php'); $smarty = new Smarty; $smarty->template_dir = SMARTY_TEST.'templates/'; $smarty->compile_dir = SMARTY_TEST.'templates_c/'; $smarty->config_dir = SMARTY_TEST.'configs/'; $smarty->cache_dir = SMARTY_TEST.'cache/'; $smarty->assign('msg','Hello World!'); $smarty->display('index.tpl'); ?> そして、このindex.phpにアクセスすると、下記のようなエラーメッセージが表示されます。 Warning: Smarty::require_once(/home/アカウント/www/libs/smarty/internals/core.write_compiled_resource.php) [smarty.require-once]: failed to open stream: No such file or directory in /home/アカウント/www/libs/smarty/Smarty.class.php on line 1429 Fatal error: Smarty::require_once() [function.require]: Failed opening required '/home/アカウント/www/libs/smarty/internals/core.write_compiled_resource.php' (include_path='.:/usr/local/php-5.2.6/lib/php') in /home/アカウント/www/libs/smarty/Smarty.class.php on line 1429 Smarty.class.phpの1429行目に問題があるのかとファイルを開いてみたものの、初心者のためよく理解できません。あと、Smarty.class.phpを呼び出すのに絶対パスを指定しているのは、さくらの管理画面からphp.iniでinclude_pathを指定しようとしても、うまくいかなかったためです(上記の場合、$smarty = new Smarty;を削除すれば、エラー画面は表示されません。変わりに何も表示されませんが・・)。 初心者のため、基本的なところで見落としがあるのかもしれませんが、教えて頂ければと思います。どうか、宜しくお願いします。

    • 締切済み
    • PHP
  • いつもお世話になっております。

    いつもお世話になっております。 小生、只今WindowsXPSP3上でXAMPP1.7.1を使用し、PHPを勉強しているPHP初心者です。 今回皆様にご質問させて頂きたい内容はXAMPPにSmatyをインストールするべきかしないべきかです。 私の環境でXAMPPのフォルダ内で「smarty」というキーワードを入れ、検索してみたところ、以下のファイルが検出されました。 smarty ディレクトリ     C:\xampp\htdocs\xoops\class Smarty.class.php       C:\xampp\htdocs\xoops\class\smarty Smarty_Compiler.class.php   C:\xampp\htdocs\xoops\class\smarty Smarty-2.6.0 ディレクトリ  C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor core.assign_smarty_interface.php C:\xampp\htdocs\xoops\class\smarty\core core.smarty_include_php.php  C:\xampp\htdocs\xoops\class\smarty\core SmartyTask.php C:\xampp\php\PEAR\phing\tasks\ext smarty ディレクトリ C:\xampp\htdocs\extras\extra_languages\pt_utf8\html\class Smarty ディレクトリ C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Converters\HTML Smarty.class.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs Smarty_Compiler.class.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs HTMLSmartyConverter.inc C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Converters\HTML\Smarty core.assign_smarty_interface.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs\core core.smarty_include_php.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs\core 以上のファイルがあっても、XAMPPにSmartyをインストールしなければ、Smartyの機能は使えないのでしょうか?? また、上記の設定(Smartyをインストールしていない状態)でC:\xampp\sample\templatesフォルダを作成し、以下の.tplファイルを作成しました。 -----.tplファイル------ <html> <head> <title>smatyのテスト</title> </head> <body> ようこそ、($name)さん<br/> Hello World! </body> </html> そしてその上位フォルダにindex.phpを作成しました。 -----index.php----- <?php require_once "Smarty.class.php"; $smarty = new Smarty; $smarty->assign('name', '桃太郎'); $smarty->;display('index.tpl'); ?> 上記の2ファイルを作成し、http://localhost/sampleにアクセスしても、 「Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in C:\xampp\htdocs\sample\index.php on line 6」のエラーが出現し、正確に表示されません。 お忙しい中、大変申し訳ございませんが、先輩方アドバイス宜しくお願い致します。

    • ベストアンサー
    • PHP
  • smartyテンプレート読み込みについて

    Smarty動的Webサイト構築入門という書籍を見ながらSmartyを学習しているのですが、書籍のCD-ROMから落としたサンプルファイルを保存しているのですがどうしてもテンプレートを読み込むことができません。 03_01.php <?php require_once("../smarty/libs/Smarty.class.php"); $smarty = new Smarty(); $smarty->template_dir = "templates"; $smarty->compile_dir = "templates_c"; $smarty->assign("name", "Smartyさん"); $smarty->display("03_01.tpl"); ?> 03_01.tpl Hello, {$name}!! エラーメッセージ Warning: Smarty error: unable to read resource: "03_01.tpl" in C:\xampp\htdocs\smartybook\smarty\libs\Smarty.class.php on line 1092 03_01.phpは、C:\xampp/htdocs/smartybook/ren/に保存しています。 03_01.tplは、C:\xampp/htdocs/smartybook/templates/に保存しています。 どこが駄目なのか教えてください。 宜しくお願いします。

    • 締切済み
    • PHP
  • Smartyのテンプレートにincludeしたファイルを表示したいので

    Smartyのテンプレートにincludeしたファイルを表示したいのですが、うまくいきません。 具体的には、意図しない数値が入ってしまいます。 どうすればよいのでしょうか? ■呼び出す側 require("../../libs/Smarty.class.php"); require_once('../../lib/set_include_path.php'); $header = include("header.php"); $smarty = new Smarty(); $smarty->assign("header",$header); $smarty->display("date.html"); ■テンプレート <body> {$header}<br>日付<br> ■表示例 include("header.php"); の内容が正常表示 1 日付 include("header.php"); の内容が正常表示された後、勝手に「1」と表示されるので、困ってます。表示されないようにするにはどうすればよいでしょうか。 var_dump($header);ってしたところ、int(1) ってなるので、この1が表示されているのかと思うのですが、なんで表示されるのか、表示されないようにするにはどうすればよいか、教えてください。

    • ベストアンサー
    • PHP