私のディレクトリ構造はPHPの自動ロード
私は私だけで、適切な名前空間を(設定している<?php
.... // some other php code
spl_autoload_register(NULL, FALSE);
spl_autoload_extensions('.php');
spl_autoload_register();
classes\template::setTemplate('template/template1');
classes\template::setMaster('master');
.... // some other php code
?>
を使用していた私のconfig.phpファイル内
> Root
> -Admin // admin area
> --index.php // admin landing page, it includes ../config.php
> -classes // all classes
> ---template.php
> ---template_vars.php // this file is used inside template.php as $template_vars = new tamplate_vars();
> -templates // all templates in different folder
> --template1
> -index.php
> -config.php
以下のようなものですクラス)とルート上の私のindex.phpに私はクラス
<?php
require 'config.php';
$news_array = array('news1', 'news1'); // coming from database
$indexTemplate = new \classes\template('index');
$indexTemplate->news_list = $news_array; // news_list variable inside index template is magically created and is the object of template_vars class
$indexTemplate->render();
?>
にアクセスこれまでのところ、それは完璧に働いている、それは一時をレンダリング後半と、
をテンプレートVARSを移入が、私は管理者フォルダ内のインデックスファイルを開いたとき、それは次のようなエラー
Fatal error: Class 'classes\template_vars' not found in /home/aamir/www/CMS/classes/template.php on line 47
にこの事を解決するためにどのように任意のアイデアを提供します。これは、ルートに動作しますが、管理パネルの内側から、それはあなたがそのためのトリックを使用する必要があり、作業
どうかこのコードは私がそれを読むと痛いです。私はファイルを100 +編集したくない、と今では正常に動作しますので、先端のための – hakre