2012-08-02 97 views
0

首先抱歉,但我是一個非常大的初學者,所以如果你願意,你可以投下這個問題。FuelPHP從網址刪除公衆

所以我去了很多的教程,唯一能爲我工作的是拉出公用文件夾的內容。

而問題是我得到了一堆的錯誤。

錯誤:

Warning: require(\bootstrap.php) [function.require]: failed to open stream: No such file or directory in C:\EasyPHP\www\fuelphp\index.php on line 33 

Fatal error: require() [function.require]: Failed opening required '\bootstrap.php' (include_path='.;C:\php\pear') in C:\EasyPHP\www\fuelphp\index.php on line 33 

,所以我發現DOCROOT是C:\EasyPHP\www\fuelphp\,所以我需要拉東西,在這樣本地主機/ fuelphp /燃油/核心

原來的指數看起來像這樣

<?php 
/** 
* Set error reporting and display errors settings. You will want to change these when in production. 
*/ 
error_reporting(-1); 
ini_set('display_errors', 1); 

/** 
* Website document root 
*/ 
define('DOCROOT', __DIR__.DIRECTORY_SEPARATOR); 

/** 
* Path to the application directory. 
*/ 
define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR); 

/** 
* Path to the default packages directory. 
*/ 
define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR); 

/** 
* The path to the framework core. 
*/ 
define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR); 

// Get the start time and memory for use later 
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true)); 
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage()); 

// Boot the app 
require APPPATH.'bootstrap.php'; 

// Generate the request, execute it and send the output. 
try 
{ 
    $response = Request::forge()->execute()->response(); 
} 
catch (HttpNotFoundException $e) 
{ 
    $route = array_key_exists('_404_', Router::$routes) ? Router::$routes['_404_']->translation : Config::get('routes._404_'); 
    if ($route) 
    { 
     $response = Request::forge($route)->execute()->response(); 
    } 
    else 
    { 
     throw $e; 
    } 
} 

// This will add the execution time and memory usage to the output. 
// Comment this out if you don't use it. 
$bm = Profiler::app_total(); 
$response->body(
    str_replace(
     array('{exec_time}', '{mem_usage}'), 
     array(round($bm[0], 4), round($bm[1]/pow(1024, 2), 3)), 
     $response->body() 
    ) 
); 

$response->send(true); 

比修飾以這種

<?php 
/** 
* Set error reporting and display errors settings. You will want to change these when in production. 
*/ 
error_reporting(-1); 
ini_set('display_errors', 1); 

/** 
* Website document root 
*/ 
define('DOCROOT', '/'); 

/** 
* Path to the application directory. 
*/ 
define('APPPATH', 'fuel/app/').DIRECTORY_SEPARATOR; 

/** 
* Path to the default packages directory. 
*/ 
define('PKGPATH', 'fuel/packages/').DIRECTORY_SEPARATOR; 

/** 
* The path to the framework core. 
*/ 
define('COREPATH', 'fuel/core/').DIRECTORY_SEPARATOR; 

// Get the start time and memory for use later 
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true)); 
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage()); 

// Boot the app 
require APPPATH.'bootstrap.php'; 

// Generate the request, execute it and send the output. 
try 
{ 
    $response = Request::forge()->execute()->response(); 
} 
catch (HttpNotFoundException $e) 
{ 
    $route = array_key_exists('_404_', Router::$routes) ? Router::$routes['_404_']->translation : Config::get('routes._404_'); 
    if ($route) 
    { 
     $response = Request::forge($route)->execute()->response(); 
    } 
    else 
    { 
     throw $e; 
    } 
} 

// This will add the execution time and memory usage to the output. 
// Comment this out if you don't use it. 
$bm = Profiler::app_total(); 
$response->body(
    str_replace(
     array('{exec_time}', '{mem_usage}'), 
     array(round($bm[0], 4), round($bm[1]/pow(1024, 2), 3)), 
     $response->body() 
    ) 
); 

$response->send(true); 

現在公衆是不是在URL,但即時得到一堆錯誤,當我打開網站,我看到insted的UTS反斜槓斜槓的,但不能真正找到問題

Warning: require_once(fuel/core/classes\error.php) [function.require-once]: failed to open stream: No such file or directory in C:\EasyPHP\www\fuelphp\fuel\core\base.php on line 25 

Fatal error: require_once() [function.require]: Failed opening required 'fuel/core/classes\error.php' (include_path='.;C:\php\pear') in C:\EasyPHP\www\fuelphp\fuel\core\base.php on line 25 

可以請別人給我一個提示如何修改索引是否可以?

謝謝

回答

3

你不應該需要修改索引文件,以達到你嘗試什麼。

Fuel被設計爲位於文檔根(docroot)之上。您的docroot似乎是www /。

這意味着你的目錄結構其實應該如下:

C:\EasyPHP\fuelphp\ 
C:\EasyPHP\www\ 

的FuelPHP zip文件或混帳克隆(或但您可能獲得它)包含一個名爲public文件夾。此文件夾是您的文檔根目錄的化名,因此,在您的具體情況public/內容應該複製到www/

但是,您可以將它設置所有的文檔根目錄裏面,你要嘗試並記錄流程上FuelPHP網站here

As explained in point 3, for security reasons it is strongly advised NOT to install Fuel inside your webserver's document root.

However, there are cases where you would like to do that, [...]

In that case, you need an additional .htaccess file that you need to place in your document root, which will redirect requests to the site root to your public folder, and also modifies the rewrites to include the public folder:

<IfModule mod_rewrite.c> 
    RewriteEngine on 

    RewriteBase /public 

    RewriteRule ^(/)?$ index.php/$1 [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 

    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

的index.php的默認配置考慮到默認/燃料/文件夾的位置。就拿路徑定義如下

define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR); 

__DIR__ - Path of current working directory, i.e. wherever index.php is 
..   - go up a directory, i.e. directory above wherever index.php is 
fuel/  - Fuel folder 
core/  - Core folder within fuel/ 

realpath() - Resolves the .. to it's real location and makes sure/is correct or changes to \ depending on the OS 

你得到不同方向的斜線的原因是因爲你硬編碼/到代碼,而無需使用realpath()

+0

添加到htaccess的根,現在工作得很好,最後一個問題是可以安全使用這個htaccess的?因爲現在我可以通過這種方式訪問​​它http:// localhost/fueljob /和這種方式http:// localhost/fueljob/public,這不是一個問題嗎? – Side 2012-08-02 09:00:46

+0

這不是問題,不。如果你真的想要使用.htaccess通過後面的URL訪問它,你可以拒絕訪問,但這不是問題,是的,我會說它是安全的使用。 – 2012-08-02 09:05:08

+0

非常感謝你的幫助 – Side 2012-08-02 09:06:44

0

在您的文件:

C:\EasyPHP\www\fuelphp\public\.htaccess

設置RewriteBase這個值:/easyphp/www/fuelphp/public