Cakephp 4で作ったアプリにバッチ処理も作り足したい場合はコンソールコマンドを使うことになるが、その使用例はこうなっている
$ bin/cake hello
自分が作業していた環境(RHEL)は、phpのバージョンが7.4と8.2がどちらもインストールされており、どちらも使っている。今回8.2で実行したいが、単純にシェルでphpコマンドを打つと今は7.4が有効なので
$ bin/cake
PHP Fatal error: Your PHP version must be equal or higher than 7.4.x to use CakePHP. in /var/www/html/xxxxx/config/requirements.php on line 24
という感じでエラーが出る。そりゃそうだよね。
Webとかでもあまりはっきり書いてないけど、これで解決する。
$ php82 ./bin/cake.php
No command provided. Choose one of the available commands.
Current Paths:
* app: src/
* root: /var/www/html/xxxxx/
* core: /var/www/html/xxxxx/vendor/cakephp/cakephp/
Available Commands:
App:
- help
Bake:
- bake
- bake all
- bake behavior
- bake cell
- bake command
- bake command_helper
- bake component
- bake controller
- bake controller all
- bake fixture
- bake fixture all
- bake form
- bake helper
- bake mailer
- bake middleware
- bake model
- bake model all
- bake plugin
- bake shell_helper
- bake template
- bake template all
- bake test
Cake/TwigView:
- twig-view compile
CakePHP:
- cache clear
- cache clear_all
- cache list
- completion
- i18n
- i18n extract
- i18n init
- plugin assets copy
- plugin assets remove
- plugin assets symlink
- plugin load
- plugin loaded
- plugin unload
- routes
- routes check
- routes generate
- schema_cache build
- schema_cache clear
- server
- version
DebugKit:
- benchmark
Migrations:
- bake migration
- bake migration_diff
- bake migration_snapshot
- bake seed
- bake simple_migration
- migrations
- migrations create
- migrations dump
- migrations mark_migrated
- migrations migrate
- migrations orm-cache-build
- migrations orm-cache-clear
- migrations rollback
- migrations seed
- migrations status
To run a command, type `cake command_name [args|options]`
To get help on a specific command, type `cake command_name --help`