現在使っているFuelPHP1.7.2からFuelPHP1.8がリリースされていたのでバージョンアップをしてみたのでメモ。
まずは、composer.jsonを修正していきます。
修正元のcomposer.jsonは
https://github.com/fuel/fuel/blob/1.8/master/composer.json
になります。
早速修正していきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
- "keywords": ["application", "website", "development", "framework", "PHP"], + "keywords": ["application", "website", "development", "framework", "PHP", "PHP7"], "repositories": [ - { - "type": "package", - "package": { - "name": "fuel/auth", - "type": "fuel-package", - "version": "1.7.2", - "dist": { - "url": "https://github.com/fuel/auth/archive/1.7/master.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/fuel/auth.git", - "type": "git", - "reference": "1.8/develop" - } - } - }, - { - "type": "package", - "package": { - "name": "fuel/email", - "type": "fuel-package", - "version": "1.7.2", - "dist": { - "url": "https://github.com/fuel/email/archive/1.7/master.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/fuel/email.git", - "type": "git", - "reference": "1.8/develop" - } - } - }, - { - "type": "package", - "package": { - "name": "fuel/oil", - "type": "fuel-package", - "version": "1.7.2", - "dist": { - "url": "https://github.com/fuel/oil/archive/1.7/master.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/fuel/oil.git", - "type": "git", - "reference": "1.8/develop" - } - } - }, - { - "type": "package", - "package": { - "name": "fuel/orm", - "type": "fuel-package", - "version": "1.7.2", - "dist": { - "url": "https://github.com/fuel/orm/archive/1.7/master.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/fuel/orm.git", - "type": "git", - "reference": "1.8/develop" - } - } - }, - { - "type": "package", - "package": { - "name": "fuel/parser", - "type": "fuel-package", - "version": "1.7.2", - "dist": { - "url": "https://github.com/fuel/parser/archive/1.7/master.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/fuel/parser.git", - "type": "git", - "reference": "1.8/develop" - } - } - }, - { - "type": "package", - "package": { - "name": "fuel/core", - "type": "fuel-package", - "version": "1.7.2", - "dist": { - "url": "https://github.com/fuel/core/archive/1.7/master.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/fuel/core.git", - "type": "git", - "reference": "1.8/develop" - } - } - }, - { - "type": "package", - "package": { - "name": "fuel/docs", - "type": "fuel-package", - "version": "1.7.2", - "dist": { - "url": "https://github.com/fuel/docs/archive/1.7/master.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/fuel/docs.git", - "type": "git", - "reference": "1.8/develop" - } - } - } + { "type": "vcs", "url": "https://github.com/fuel/docs" }, + { "type": "vcs", "url": "https://github.com/fuel/core" }, + { "type": "vcs", "url": "https://github.com/fuel/auth" }, + { "type": "vcs", "url": "https://github.com/fuel/email" }, + { "type": "vcs", "url": "https://github.com/fuel/oil" }, + { "type": "vcs", "url": "https://github.com/fuel/orm" }, + { "type": "vcs", "url": "https://github.com/fuel/parser" } ], "require": { "composer/installers": "~1.0", - "fuel/docs": "1.7.2", - "fuel/core": "1.7.2", - "fuel/auth": "1.7.2", - "fuel/email": "1.7.2", - "fuel/oil": "1.7.2", - "fuel/orm": "1.7.2", - "fuel/parser": "1.7.2", - "fuelphp/upload": "2.0.1", + "fuel/core": "dev-1.8/master", + "fuel/auth": "dev-1.8/master", + "fuel/email": "dev-1.8/master", + "fuel/oil": "dev-1.8/master", + "fuel/orm": "dev-1.8/master", + "fuel/parser": "dev-1.8/master", + "fuelphp/upload": "2.0.6", "monolog/monolog": "1.5.*", + "phpseclib/phpseclib": "2.0.0", "michelf/php-markdown": "1.4.0", "mp-php/fuel-packages-gdata": "dev-master", "opauth/opauth": "0.4.*", "phpunit/phpunit": "4.6.*" }, "require-dev": { + "fuel/docs": "dev-1.8/master", "codeception/aspect-mock": "*" }, |
※コピーするときにカンマとか付け忘れたり、つけすぎたりするとcomposer updateするときにエラーとなるので注意が必用です。
では実際にバージョンアップしてみます。
まずは、self-updateから。
1 2 3 4 |
C:\xampp\htdocs\xxxx>php composer.phar self-update Updating to version 40c14709f79f9d7ea35ac969cfbd7f41beb525bb. Downloading: 100% Use composer self-update --rollback to return to version 03e0d65f378976767dde7d59e2ace39bc914dbfd |
うまくいったので、続いて、updateをしていきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
C:\xampp\htdocs\xxxx>php composer.phar update Loading composer repositories with package information Updating dependencies (including require-dev) - Updating composer/installers dev-master (0d061bf => 1cf7cc4) Checking out 1cf7cc4b89d5e8549bbb7d6ab1de75da13d27988 - Removing fuel/core (1.7.2) - Installing fuel/core (dev-1.8/master 26f6432) Cloning 26f6432a9f41659280c70ba47c16170adf1e7611 - Removing fuel/auth (1.7.2) - Installing fuel/auth (dev-1.8/master a645dbe) Cloning a645dbe2f80b6b4cecb069b57ea70150b6e53929 - Removing fuel/email (1.7.2) - Installing fuel/email (dev-1.8/master 79133b3) Cloning 79133b3951068bbcff9a9c7b77f9f27a777ebdbd - Removing fuel/oil (1.7.2) - Installing fuel/oil (dev-1.8/master b29b80f) Cloning b29b80f29f090b9ad12b931da6e979587de6ced1 - Removing fuel/orm (1.7.2) - Installing fuel/orm (dev-1.8/master 2c1da63) Cloning 2c1da635127c9fbedc9c76132fc904188892c365 - Removing fuel/parser (1.7.2) - Installing fuel/parser (dev-1.8/master bec50ec) Cloning bec50ec304e696d72dba7f13494828532c6e18df - Removing fuelphp/upload (2.0.1) - Installing fuelphp/upload (2.0.6) Downloading: 100% - Removing fuel/docs (1.7.2) - Installing fuel/docs (dev-1.8/master e03906d) Cloning e03906d02cbd09bddb653e28f92f92056e673a32 - Installing phpseclib/phpseclib (2.0.0) Loading from cache - Updating doctrine/instantiator dev-master (8e884e7 => 416fb8a) Checking out 416fb8ad1d095a87f1d21bc40711843cd122fd4a - Updating symfony/yaml dev-master (38aebd1 => 407e31a) Checking out 407e31ad9742ace5c3d01642f02a3b2e6062bae5 - Updating doctrine/annotations dev-master (07a9af2 => 2e1b1f7) Checking out 2e1b1f7597e2f647e99e96e747fcae9718ac817b - Updating goaop/framework 1.x-dev (6ac59e6 => 379f5ca) Checking out 379f5ca8bd1bc20ad09760ab2ca4255826ed3f21 - Updating codeception/aspect-mock dev-master (666d0a8 => d8e8c85) Checking out d8e8c8545ceaf6f3f317b9b5973590231b44acdf phpseclib/phpseclib suggests installing ext-libsodium (SSH2/SFTP can make use of some algorithms providedby the libsodium-php extension.) phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.) phpseclib/phpseclib suggests installing pear-pear/PHP_Compat (Install PHP_Compat to get phpseclib workingon PHP < 5.0.0.) Writing lock file Generating autoload files |
無事アップデートが完了しました。
2016/4/12 追記
Twitterにて下記のご指摘頂いたので、追記いたします。
@shinn_droid 1.8.0ではfuel/app/bootstrap.php, public/.htaccess, public/index.phpも変更されています。必要な更新は手動でする必要がありますのでご確認ください
— 『はじフレFuelPHP』 (@fuelphp1st) 2016年4月11日
手動で以下のファイルを修正していきます。
修正元のfuel/app/bootstrap.phpは
https://github.com/fuel/fuel/blob/1.8/master/fuel/app/bootstrap.php
になります。
修正していきます。
1 2 3 4 5 6 7 8 9 10 11 |
-Autoloader::add_classes(array( +\Autoloader::add_classes(array( -Autoloader::register(); +\Autoloader::register(); -Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT); +\Fuel::$env = \Arr::get($_SERVER, 'FUEL_ENV', \Arr::get($_ENV, 'FUEL_ENV', \Fuel::DEVELOPMENT)); -Fuel::init('config.php'); +\Fuel::init('config.php'); |
修正元のpublic/.htaccessは
https://github.com/fuel/fuel/blob/1.8/master/public/.htaccess
になります。
修正していきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
- RewriteCond %{HTTPS} off - RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L] - # make HTTP Basic Authentication work on php5-fcgi installs + # make HTTP Basic Authentication work on php-fcgi installs - # deal with php5-cgi first + # deal with php-fcgi first - # for normal Apache installations + # for PHP5 sapi installations - RewriteRule ^(.*)$ index.php?/$1 [QSA,L] + + # for PHP7 sapi installations + <IfModule mod_php7.c> + RewriteRule ^(.*)$ index.php/$1 [L] + </IfModule> + + # for fpm installations + <IfModule !mod_php7.c> + RewriteRule ^(.*)$ index.php?/$1 [QSA,L] + </IfModule> |
修正元のpublic/index.phpは
https://github.com/fuel/fuel/blob/1.8/master/public/index.php
になります。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
+if ( ! file_exists(COREPATH.'classes'.DIRECTORY_SEPARATOR.'autoloader.php')) +{ + die('No composer autoloader found. Please run composer to install the FuelPHP framework dependencies first!'); +} +// Activate the framework class autoloader require COREPATH.'classes'.DIRECTORY_SEPARATOR.'autoloader.php'; class_alias('Fuel\\Core\\Autoloader', 'Autoloader'); - -// Boot the app -require APPPATH.'bootstrap.php'; - -// Generate the request, execute it and send the output. -try +// Exception route processing closure +$routerequest = function($route = null, $e = false) { - $response = Request::forge()->execute()->response(); -} -catch (HttpNotFoundException $e) -{ - \Request::reset_request(true); - - $route = array_key_exists('_404_', Router::$routes) ? Router::$routes['_404_']->translation : Config::get('routes._404_'); - - if($route instanceof Closure) + Request::reset_request(true); + $route = array_key_exists($route, Router::$routes) ? Router::$routes[$route]->translation : Config::get('routes.'.$route); + if ($route instanceof Closure) { $response = $route(); - if( ! $response instanceof Response) { $response = Response::forge($response); } } + elseif ($e === false) + { + $response = Request::forge()->execute()->response(); + } elseif ($route) { - $response = Request::forge($route, false)->execute()->response(); + $response = Request::forge($route, false)->execute(array($e))->response(); } else { throw $e; } + return $response; +}; +// Generate the request, execute it and send the output. +try +{ + // Boot the app... + require APPPATH.'bootstrap.php'; + // ... and execute the main request + $response = $routerequest(); } - -// Render the output +catch (HttpBadRequestException $e) +{ + $response = $routerequest('_400_', $e); +} +catch (HttpNoAccessException $e) +{ + $response = $routerequest('_403_', $e); +} +catch (HttpNotFoundException $e) +{ + $response = $routerequest('_404_', $e); +} +catch (HttpServerErrorException $e) +{ + $response = $routerequest('_500_', $e); +} +// This will add the execution time and memory usage to the output. +// Comment this out if you don't use it. $response->body((string) $response); - -// 本番では表示しない -if (\Fuel::$env !== \Fuel::PRODUCTION) { - // This will add the execution time and memory usage to the output. - // Comment this out if you don't use it. - if (strpos($response->body(), '{exec_time}') !== false or strpos($response->body(), '{mem_usage}') !== false) - { - $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() - ) - ); - } +if (strpos($response->body(), '{exec_time}') !== false or strpos($response->body(), '{mem_usage}') !== false) +{ + $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); +// Send the output to the client +$response->send(true); \ No newline at end of file |
One comment to this article
Pingback:
【FuelPHP】1.7.2から1.8.0へバージョンアップしてみた 修正版 | プログラマのめもぶろぐ