XAMPPにSmartyをインストールするべきか?

このQ&Aのポイント
  • XAMPPのフォルダ内にはSmarty関連のファイルがありますが、インストールしなければ機能は使えませんか?
  • Smartyのテストファイルを作成し、表示する際にエラーが出現します。
  • 質問:XAMPPにSmartyをインストールするべきかしないべきか
回答を見る
  • ベストアンサー

いつもお世話になっております。

いつもお世話になっております。 小生、只今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
  • 回答数2
  • ありがとう数11

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

  • ベストアンサー
  • qaqa246
  • ベストアンサー率27% (45/163)
回答No.2

>XOOPS上にSmartyが入ってる場合、XAMPP側の方に個別にSmartyをインストールできないのでしょうか?? できる。 XOOPS以下の物はXOOPS用と考えておけばいい。

HackHack
質問者

補足

qaqa246さん、ご親切に再度、ご回答頂き心より感謝申し上げます。 ご指摘のあった通り、私でも出来ると確信し、他のサイト様のhttp://blog.quall.net/program/56/記事を拝見させて頂き、設定どおりに作業を進めて行ったのですが、 どうしても、Smarty.class.phpがオープン出来ないとメッセージが出てしまいます。 何度も申し訳ございませんが、ご教示宜しくお願い致します。 本当に申し訳ございません。

その他の回答 (1)

  • qaqa246
  • ベストアンサー率27% (45/163)
回答No.1

XOOPSインストールしているのか? XOOPSのテンプレートにはSmartyが使われているから入っているのは当たり前だと思うけど

HackHack
質問者

補足

qaqa246さん、ご回答頂き誠にありがとうございます。 >XOOPSインストールしているのか? はい、インストールしています。 XOOPS上にSmartyが入ってる場合、XAMPP側の方に個別にSmartyをインストールできないのでしょうか?? 申し訳ございませんが、再度ご教示お願い致します。

関連するQ&A

  • 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について

    smartyについて 環境は、windows /php-5 / smarty-2.6.17です。 以下の2つエラーが出てどう対処すればいいか困っています。 【1つめ】 Fatal error: Smarty error: [in **.tpl line 10]: syntax error: unrecognized tag: 文--> 【2つめ】 {$errmsg (Smarty_Compiler.class.php, line 446) in C:\xampp\php\PEAR\Smarty\libs\Smarty.class.php on line 1095 【ソース】 呼び先PGは、 $this->smarty->assign("errmsg","ニックネーム"); $this->smarty->display("**.tpl"); テンプレートでは、 <tr id="" class=""> <td id="" class=""><font color="#ff0000">{$errmsg}を入力してください。</font></td> </tr> よろしくお願いいたします。

    • 締切済み
    • PHP
  • tplを読みに行けません。

    PHP+smartyを学んでいます。 Apache2-htdocs-taro-hanako.php とファイルを置き、一方、 Apache2-php_libs-smarty の下に -libs/ (中にSmarty.class.php あり) と -templates/ (中にtest.tpl あり)を並列的におきました。 hanako.php に、 require_once "../../php_libs/smarty/libs/Smarty.class.php"; $smarty = new Smarty; $smarty->templete_dir = "../../php_libs/smarty/templates";   $smarty->compile_dir = "../../php_libs/smarty/templates_c"; $smarty->cache_dir = "../../php_libs/smarty/cache"; 以下省略・・・ と書いてブラウザで開くと、次のエラーが出て、tpl を読み込むことが出来ません。 Warning: Smarty error: unable to read resource: "test.tpl" in C:\Program Files\Apache Group\Apache2\php_libs\smarty\libs\Smarty.class.php on line 1088 どこを間違えているのでしょうか。

    • ベストアンサー
    • PHP
  • 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がなくても、アプリケーション開発に支障はありませんでしょうか。 あくまで個人で趣味の範囲でアプリケーションを作成したいと感じています。

    • ベストアンサー
    • 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
  • Smartyに関しまして

    require_once("Smarty/Smarty.class.php"); $smarty = new Smarty(); $smarty->template_dir = "./templates"; $smarty->compile_dir = "./templates_c"; $smarty->assign("message", "こんばんは"); $a = array('hello','php','html'); $smarty->assign('a',$a); $smarty->display("index.tpl"); これでindex.tplで出力すると日本語部分が「?????」になってしまいます。 何か設定がいるんでしょうか??

    • ベストアンサー
    • PHP
  • 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
  • 共通テンプレートを呼ぶ

    src/common/header.tplを src/hoge/hoge.tplから {include file="../common/header.tpl"} として呼びだしたい。 エラーメッセージが Warning: Smarty error: (secure mode) accessing "../common/header.tpl" is not allowed in C:\php\libs\Smarty.class.php on line 1088 です。 #### 設定 php.ini include_path = ".;C:\php\libs;C:\php\PEAR" safe_mode = Off Smarty.class.php $smarty->template_dir="."; {include file}を絶対パスで記述しても同じエラーです。 おそらくこのsecure modeの設定が正しく設定されていないのでしょうが その設定方法がいまいちよくわかりません。 簡単なことなのかもしれませんが、ご存知の方がいらっしゃいましたら ご教授願えないでしょうか。 よろしくお願いいたします。 環境 Windows XP php-5.0.5 Smarty-2.6.10

    • 締切済み
    • PHP
  • Smartyについて教えてください。

    Smartyについて教えてください。 参考書によってテンプレートの存在するディレクトリを指定している場合(1)と していない場合(2)がありますが、 どちらが正しいのでしょうか? (1) ********************************************* require_once('smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->template_dir = "template02/"; $smarty->compile_dir = "compile/"; $smarty->display("content.tpl"); ********************************************* (2) ********************************************* require_once('smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->display("content.tpl"); *********************************************

    • ベストアンサー
    • PHP
  • ロリポップでSmartyのtpl読み込みエラー

    下記のコードを実行すると、  Smarty error: unable to read resource: "template1.tpl"  というエラーが出てしまいます。 $smarty->template_dirで指定したディレクトリ名の中に  "template1.tpl"というファイルは配置してあります。  原因などわかればおしえていただけないでしょうか。 index.php <?php require_once("Smarty.class.php"); $smarty = new Smarty; $smarty->template_dir = './templates/'; $smarty->compile_dir = './templates_c/'; $smarty->config_dir = './configs/'; $smarty->cache_dir = './cache/'; $smarty->display("template1.tpl"); ?> 【サーバ】  ロリポップです。 【その他】 index.phpをホームディレクトリ配下におくとエラーは消えます。 【ディレクトリ構成】 modules/index.php と templates/template1.tpl をがあり、 index.php から template1.tpl を読み込もうとしています。  ・modules →index.php ・templates →template1.tpl

    • ベストアンサー
    • PHP