ZipファイルからインストールしたCodeIgniter4をComposerに変更する
動作確認環境
- CodeIgniter 4.0.4 -> 4.1.5
- PHP 7.3.31
- macOS 10.15.7
Zipファイルからのインストール
Zipファイルを展開します。
$ unzip framework-4.0.4.zip
ソースコードをGit管理します。
$ cd framework-4.0.4/
$ git init
$ git add .
$ git commit -m "chore: framework-4.0.4.zip"
composer.jsonの変更
appstarterの composer.json に変更します。
composer.json
を以下で上書きします。
{
"name": "codeigniter4/appstarter",
"type": "project",
"description": "CodeIgniter4 starter app",
"homepage": "https://codeigniter.com",
"license": "MIT",
"require": {
"php": "^7.3 || ^8.0",
"codeigniter4/framework": "^4"
},
"require-dev": {
"fakerphp/faker": "^1.9",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^9.1"
},
"suggest": {
"ext-fileinfo": "Improves mime type detection for files"
},
"autoload": {
"psr-4": {
"App\\": "app",
"Config\\": "app/Config"
},
"exclude-from-classmap": [
"**/Database/Migrations/**"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\Support\\": "tests/_support"
}
},
"scripts": {
"test": "phpunit"
},
"support": {
"forum": "http://forum.codeigniter.com/",
"source": "https://github.com/codeigniter4/CodeIgniter4",
"slack": "https://codeigniterchat.slack.com"
}
}
composer update
します。
$ composer update
codeigniter4/framework (v4.1.5) がインストールされました。
tatter/patchesのインストール
フレームワーク以外のファイルの更新をサポートするツールである tatter/patches をインストールします。
$ composer require --dev tatter/patches
フレームワーク以外のファイルの更新
tatter/patchesを実行します。-c
オプションでZipインストールしたCodeIgniterのバージョンを指定します。
$ vendor/bin/patch -c 4.0.4
~/tmp/framework-4.0.4 (main)$ vendor/bin/patch -c 4.0.4
git version 2.33.1
Composer version 2.1.9 2021-10-05 09:47:38
************************************
* CONFIGURATION *
************************************
Scripts Directory: vendor/bin
Project Directory: /Users/kenji/tmp/framework-4.0.4
Target Version:
Current Version:
Source Package: codeigniter4/framework
Base Branch: main
Selected Items: app/ public/ env spark
************************************
* STAGING *
************************************
Switched to a new branch 'tatter/scratch'
./composer.json has been updated
Running composer update codeigniter4/framework
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Downgrading codeigniter4/framework (v4.1.5 => v4.0.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downgrading codeigniter4/framework (v4.1.5 => v4.0.4): Extracting archive
Generating autoload files
29 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
infection/extension-installer: No extensions found
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Upgrading codeigniter4/framework (v4.0.4 => v4.1.5): Extracting archive
Generating autoload files
29 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
infection/extension-installer: No extensions found
[tatter/scratch 5ce6011] Patch framework
52 files changed, 4175 insertions(+), 3184 deletions(-)
rewrite Config/App.php (99%)
rewrite Config/Autoload.php (75%)
rewrite Config/Boot/development.php (84%)
rewrite Config/Boot/production.php (75%)
rewrite Config/Boot/testing.php (83%)
create mode 100644 Config/CURLRequest.php
rewrite Config/Cache.php (97%)
rewrite Config/Constants.php (60%)
rewrite Config/ContentSecurityPolicy.php (76%)
create mode 100644 Config/Cookie.php
rewrite Config/Database.php (97%)
rewrite Config/DocTypes.php (98%)
rewrite Config/Email.php (94%)
rewrite Config/Encryption.php (73%)
rewrite Config/Exceptions.php (89%)
create mode 100644 Config/Feature.php
rewrite Config/Filters.php (91%)
rewrite Config/Format.php (96%)
create mode 100644 Config/Generators.php
rewrite Config/Honeypot.php (87%)
rewrite Config/Images.php (88%)
rewrite Config/Kint.php (93%)
rewrite Config/Logger.php (98%)
rewrite Config/Migrations.php (94%)
rewrite Config/Mimes.php (99%)
rewrite Config/Modules.php (97%)
rewrite Config/Pager.php (92%)
rewrite Config/Paths.php (89%)
create mode 100644 Config/Publisher.php
create mode 100644 Config/Security.php
rewrite Config/Toolbar.php (95%)
rewrite Config/UserAgents.php (98%)
rewrite Config/Validation.php (97%)
rewrite Config/View.php (99%)
rewrite Controllers/BaseController.php (63%)
rewrite Views/errors/cli/error_exception.php (99%)
rewrite Views/errors/html/debug.css (78%)
rewrite Views/errors/html/debug.js (97%)
rewrite Views/errors/html/error_404.php (72%)
Switched to a new branch 'tatter/patches'
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
29 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
************************************
* MERGING *
************************************
CONFLICT (file location): Config/Security.php added in 5ce6011 (Patch framework) inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to app/Config/Security.php.
CONFLICT (file location): Config/Publisher.php added in 5ce6011 (Patch framework) inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to app/Config/Publisher.php.
CONFLICT (file location): Config/Generators.php added in 5ce6011 (Patch framework) inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to app/Config/Generators.php.
CONFLICT (file location): Config/Feature.php added in 5ce6011 (Patch framework) inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to app/Config/Feature.php.
CONFLICT (file location): Config/Cookie.php added in 5ce6011 (Patch framework) inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to app/Config/Cookie.php.
CONFLICT (file location): Config/CURLRequest.php added in 5ce6011 (Patch framework) inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to app/Config/CURLRequest.php.
error: could not apply 5ce6011... Patch framework
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
On branch tatter/patches
You are currently cherry-picking commit 5ce6011.
(fix conflicts and run "git cherry-pick --continue")
(use "git cherry-pick --skip" to skip this patch)
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
Changes to be committed:
modified: app/Common.php
modified: app/Config/App.php
modified: app/Config/Autoload.php
modified: app/Config/Boot/development.php
modified: app/Config/Boot/production.php
modified: app/Config/Boot/testing.php
modified: app/Config/Cache.php
modified: app/Config/Constants.php
modified: app/Config/ContentSecurityPolicy.php
modified: app/Config/Database.php
modified: app/Config/DocTypes.php
modified: app/Config/Email.php
modified: app/Config/Encryption.php
modified: app/Config/Events.php
modified: app/Config/Exceptions.php
modified: app/Config/Filters.php
modified: app/Config/ForeignCharacters.php
modified: app/Config/Format.php
modified: app/Config/Honeypot.php
modified: app/Config/Images.php
modified: app/Config/Kint.php
modified: app/Config/Logger.php
modified: app/Config/Migrations.php
modified: app/Config/Mimes.php
modified: app/Config/Modules.php
modified: app/Config/Pager.php
modified: app/Config/Paths.php
modified: app/Config/Routes.php
modified: app/Config/Services.php
modified: app/Config/Toolbar.php
modified: app/Config/UserAgents.php
modified: app/Config/Validation.php
modified: app/Config/View.php
modified: app/Controllers/BaseController.php
modified: app/Controllers/Home.php
modified: app/Views/errors/cli/error_404.php
modified: app/Views/errors/cli/error_exception.php
modified: app/Views/errors/html/debug.css
modified: app/Views/errors/html/debug.js
modified: app/Views/errors/html/error_404.php
modified: app/Views/errors/html/error_exception.php
modified: app/Views/welcome_message.php
modified: env
modified: public/.htaccess
modified: public/index.php
modified: spark
Unmerged paths:
(use "git add <file>..." to mark resolution)
added by them: app/Config/CURLRequest.php
added by them: app/Config/Cookie.php
added by them: app/Config/Feature.php
added by them: app/Config/Generators.php
added by them: app/Config/Publisher.php
added by them: app/Config/Security.php
************************************
* RESOLUTION *
************************************
Conflicts detected during patch! Follow the git instructions for resolution.
Once resolution is complete your changes will be available on branch tatter/patches
and you should remove the old working branch at tatter/scratch.
~/tmp/framework-4.0.4 (tatter/patches *+|CHERRY-PICKING)$
コンフリクトを手動で修正します。
修正したら、cherry-pickを完了します。
$ git add -u
$ git cherry-pick --continue
全ての変更がtatter/patches
ブランチにコミットされました。
$ git log --oneline --graph
* 49e8ac6 (HEAD -> tatter/patches) Patch framework
* 14353f3 (main) chore: composer require --dev tatter/patches
* da9bf12 chore: composer update
* 0d63d1a chore: update composer.json from appstarter
* a4e451b chore: framework-4.0.4.zip
systemパスの変更
不要になった system/
を削除します。
$ git rm -r system/
パスの設定を変更します。
--- a/app/Config/Paths.php
+++ b/app/Config/Paths.php
@@ -25,7 +25,7 @@ class Paths
*
* @var string
*/
- public $systemDirectory = __DIR__ . '/../../system';
+ public $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system';
/**
* ---------------------------------------------------------------
アプリケーションコードの更新
Upgrading From a Previous Version — CodeIgniter 4.1.5 documentation をよく読んで、互換性のない変更があれば、対処します。
動作の確認
ビルトインサーバを起動して、http://localhost:8080
にアクセスします。
$ php spark serve
うまく行けば、ページが正常に表示されます。
関連
Date: 2021/11/12