Last active
December 29, 2015 19:18
-
-
Save sharkpp/7716098 to your computer and use it in GitHub Desktop.
Phar::webPhar() を使い FuelPHP 1.7 を動かすための変更点
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff U5 fuel/app/config/asset.php fuel/app/config/asset.php | |
--- fuel/app/config/asset.php Thu Jan 01 09:00:00 1970 | |
+++ fuel/app/config/asset.php Sat Nov 30 11:49:43 2013 | |
@@ -0,0 +1,110 @@ | |
+<?php | |
+/** | |
+ * Part of the Fuel framework. | |
+ * | |
+ * @package Fuel | |
+ * @version 1.7 | |
+ * @author Fuel Development Team | |
+ * @license MIT License | |
+ * @copyright 2010 - 2013 Fuel Development Team | |
+ * @link http://fuelphp.com | |
+ */ | |
+ | |
+/** | |
+ * NOTICE: | |
+ * | |
+ * If you need to make modifications to the default configuration, copy | |
+ * this file to your app/config folder, and make them in there. | |
+ * | |
+ * This will allow you to upgrade fuel without losing your custom config. | |
+ */ | |
+ | |
+ | |
+return array( | |
+ | |
+ /** | |
+ * An array of paths that will be searched for assets. Each path is a | |
+ * RELATIVE path from the speficied url: | |
+ * | |
+ * array('assets/') | |
+ * | |
+ * These MUST include the trailing slash ('/') | |
+ * | |
+ * Paths specified here are suffixed with the sub-folder paths defined below. | |
+ */ | |
+ 'paths' => array(DOCROOT . 'assets/'), | |
+ | |
+ /** | |
+ * Asset Sub-folders | |
+ * | |
+ * Names for the img, js and css folders (inside the asset search path). | |
+ * | |
+ * Examples: | |
+ * | |
+ * img/ | |
+ * js/ | |
+ * css/ | |
+ * | |
+ * This MUST include the trailing slash ('/') | |
+ */ | |
+ 'img_dir' => 'img/', | |
+ 'js_dir' => 'js/', | |
+ 'css_dir' => 'css/', | |
+ | |
+ /** | |
+ * You can also specify one or more per asset-type folders. You don't have | |
+ * to specify all of them. * Each folder is a RELATIVE path from the url | |
+ * speficied below: | |
+ * | |
+ * array('css' => 'assets/css/') | |
+ * | |
+ * These MUST include the trailing slash ('/') | |
+ * | |
+ * Paths specified here are expected to contain the assets they point to | |
+ */ | |
+ 'folders' => array( | |
+ 'css' => array(), | |
+ 'js' => array(), | |
+ 'img' => array(), | |
+ ), | |
+ | |
+ /** | |
+ * URL to your Fuel root. Typically this will be your base URL: | |
+ * | |
+ * Config::get('base_url') | |
+ * | |
+ * These MUST include the trailing slash ('/') | |
+ */ | |
+ 'url' => Config::get('base_url').(0===strpos(__DIR__,'phar://')?'index.phar/':''), | |
+ | |
+ /** | |
+ * Whether to append the assets last modified timestamp to the url. | |
+ * This will aid in asset caching, and is recommended. It will create | |
+ * tags like this: | |
+ * | |
+ * <link type="text/css" rel="stylesheet" src="/assets/css/styles.css?1303443763" /> | |
+ */ | |
+ 'add_mtime' => false, | |
+ | |
+ /** | |
+ * The amount of indents to prefix to the generated asset tag(s). | |
+ */ | |
+ 'indent_level' => 1, | |
+ | |
+ /** | |
+ * What to use for indenting. | |
+ */ | |
+ 'indent_with' => "\t", | |
+ | |
+ /** | |
+ * What to do when an asset method is called without a group name. If true, it will | |
+ * return the generated asset tag. If false, it will add it to the default group. | |
+ */ | |
+ 'auto_render' => true, | |
+ | |
+ /** | |
+ * Set to true to prevent an exception from being throw when a file is not found. | |
+ * The asset will then be skipped. | |
+ */ | |
+ 'fail_silently' => false, | |
+); | |
diff U5 fuel/app/config/config.php fuel/app/config/config.php | |
--- fuel/app/config/config.php Sun Nov 24 17:04:47 2013 | |
+++ fuel/app/config/config.php Sat Nov 30 11:15:23 2013 | |
@@ -47,11 +47,11 @@ | |
// 'profiling' => false, | |
/** | |
* Default location for the file cache | |
*/ | |
- // 'cache_dir' => APPPATH.'cache/', | |
+ 'cache_dir' => canonicalizePath(str_replace('phar://', '', APPPATH).'../../../writable/cache/'), | |
/** | |
* Settings for the file finder cache (the Cache class has it's own config!) | |
*/ | |
// 'caching' => false, | |
@@ -105,11 +105,11 @@ | |
* Fuel::L_DEBUG | |
* Fuel::L_INFO | |
* Fuel::L_ALL | |
*/ | |
// 'log_threshold' => Fuel::L_WARNING, | |
- // 'log_path' => APPPATH.'logs/', | |
+ 'log_path' => canonicalizePath(str_replace('phar://', '', APPPATH).'../../../writable/logs/'), | |
// 'log_date_format' => 'Y-m-d H:i:s', | |
/** | |
* Security settings | |
*/ | |
diff U5 fuel/core/classes/file/area.php fuel/core/classes/file/area.php | |
--- fuel/core/classes/file/area.php Sun Nov 24 17:06:56 2013 | |
+++ fuel/core/classes/file/area.php Sat Nov 30 02:17:49 2013 | |
@@ -52,11 +52,11 @@ | |
} | |
} | |
if ( ! empty($this->basedir)) | |
{ | |
- $this->basedir = realpath($this->basedir) ?: $this->basedir; | |
+ $this->basedir = realpat_($this->basedir) ?: $this->basedir; | |
} | |
} | |
/** | |
* Factory for area objects | |
@@ -147,16 +147,16 @@ | |
isset($pathinfo['dirname']) or $pathinfo['dirname'] = ''; | |
// do we have a basedir, and is the path already prefixed by the basedir? then just deal with the double dots... | |
if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) == $this->basedir) | |
{ | |
- $pathinfo['dirname'] = realpath($pathinfo['dirname']); | |
+ $pathinfo['dirname'] = realpat_($pathinfo['dirname']); | |
} | |
else | |
{ | |
// attempt to get the realpath(), otherwise just use path with any double dots taken out when basedir is set (for security) | |
- $pathinfo['dirname'] = ( ! empty($this->basedir) ? realpath($this->basedir.DS.$pathinfo['dirname']) : realpath($pathinfo['dirname']) ) | |
+ $pathinfo['dirname'] = ( ! empty($this->basedir) ? realpat_($this->basedir.DS.$pathinfo['dirname']) : realpat_($pathinfo['dirname']) ) | |
?: ( ! empty($this->basedir) ? $this->basedir.DS.str_replace('..', '', $pathinfo['dirname']) : $pathinfo['dirname']); | |
} | |
// basedir prefix is required when it is set (may cause unexpected errors when realpath doesn't work) | |
if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) != $this->basedir) | |
diff U5 fuel/core/bootstrap.php fuel/core/bootstrap.php | |
--- fuel/core/bootstrap.php Sun Nov 24 17:06:56 2013 | |
+++ fuel/core/bootstrap.php Sat Nov 30 12:02:23 2013 | |
@@ -8,11 +8,11 @@ | |
* @license MIT License | |
* @copyright 2010 - 2013 Fuel Development Team | |
* @link http://fuelphp.com | |
*/ | |
-define('DS', DIRECTORY_SEPARATOR); | |
+define('DS', '/'); | |
define('CRLF', chr(13).chr(10)); | |
setup_autoloader(); | |
// Load the base functions | |
@@ -25,11 +25,11 @@ | |
define('MBSTRING', function_exists('mb_get_info')); | |
/** | |
* Load the Composer autoloader if present | |
*/ | |
-defined('VENDORPATH') or define('VENDORPATH', realpath(COREPATH.'..'.DS.'vendor').DS); | |
+defined('VENDORPATH') or define('VENDORPATH', realpat_(COREPATH.'..'.DS.'vendor').DS); | |
if ( ! is_file(VENDORPATH.'autoload.php')) | |
{ | |
die('Composer is not installed. Please run "php composer.phar update" in the root to install Composer'); | |
} | |
require VENDORPATH.'autoload.php'; | |
diff U5 public/index.php public/index.php | |
--- public/index.php Sun Nov 24 17:04:48 2013 | |
+++ public/index.php Sat Nov 30 12:10:52 2013 | |
@@ -14,29 +14,43 @@ | |
* Set error reporting and display errors settings. You will want to change these when in production. | |
*/ | |
error_reporting(-1); | |
ini_set('display_errors', 1); | |
+function canonicalizePath($path) { | |
+ $path = 0===strpos($path,'phar://')?'phar://'.preg_replace('!//!', '/', substr($path,7)) | |
+ :preg_replace('!//!', '/', $path); | |
+ do { | |
+ $tmp = $path; | |
+ $path = preg_replace('!/[^/]+/\.\./!', '/', $tmp); | |
+ } while ($tmp != $path); | |
+ return rtrim($path, '/'); | |
+} | |
+ | |
+function realpat_($path) { | |
+ return canonicalizePath(str_replace(array('/', '\\'), '/', $path)); | |
+} | |
+ | |
/** | |
* Website document root | |
*/ | |
-define('DOCROOT', __DIR__.DIRECTORY_SEPARATOR); | |
+define('DOCROOT', realpat_(__DIR__).'/'); | |
/** | |
* Path to the application directory. | |
*/ | |
-define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR); | |
+define('APPPATH', realpat_(__DIR__.'/../fuel/app/').'/'); | |
/** | |
* Path to the default packages directory. | |
*/ | |
-define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR); | |
+define('PKGPATH', realpat_(__DIR__.'/../fuel/packages/').'/'); | |
/** | |
* The path to the framework core. | |
*/ | |
-define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR); | |
+define('COREPATH', realpat_(__DIR__.'/../fuel/core/').'/'); | |
// 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()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment