totara-docker-dev
totara-docker-dev copied to clipboard
Add tphp command
This PR adds a tphp command for executing commands inside the php container.
Example:
sc ~/c/t/learn> tdb drop
Successfully dropped pgsql14 database learn_17
sc ~/c/t/learn> tdb create
Successfully created pgsql14 database learn_17
sc ~/c/t/learn> tphp install
Using PHP Container: php-8.1
Running Command: php server/admin/cli/install_database.php --adminpass=admin [email protected] --agree-license --shortname=Totara 17 development site --fullname=Totara 17 development site
Totara 17.0+ (Build: 20221108.00) command line installation program
-------------------------------------------------------------------------------
== Setting up database ==
-->System
++ Success ++
-->totara_core
++ Success ++
This makes it a bit more convenient to use the install/cron/purge/etc aliases without needing to tbash in to the container.
I've been using it locally for a while and discovered some issues with handling of args recently, will just convert it to a draft until I fix those
I've been using it locally for a while and discovered some issues with handling of args recently, will just convert it to a draft until I fix those
Hey @scq how far are you away from converting this back to a regular merge request and get it in? Would be a great addition.
@derschatta I still need to solve the issue with passing arguments -- it will fail if it gets passed arguments that are too complex. I'll try and take a look at this again to get that working :D
Fixed the issues. Bash is currently broken though, so it needs #282 first.
Things you can do:
-
tphp
-- start your preferred shell in the php container (make sure to set INTERACTIVE_SHELL in .env) -
tphp ls
-- run arbitrary commands in the php container -
tphp install
-- run sh aliases -
tphp dev/approval/simple/create_demo.php
-- run php scripts -
tphp server/admin/tool/task/cli/schedule_task.php --execute='\tool_diagnostic\task\delete_diagnostic_files_task'
-- run complex commands
It autodetects if the first argument ends in .php and adds php
on to the beginning, because I found that I kept leaving it off (and tphp php ...
looks a little weird)
Changed INTERACTIVE_SHELL
default to zsh
, seems like hardly anybody is using bash
given #282
There must be something specific needed for MacOS as I get:
/Users/username/folder/totara/docker/bin/tphp: line 13: ${i@Q}: bad substitution
when I try to use the command.
Oh weird. I think Apple ships an ancient bash version that doesn't seem to support that parameter expansion syntax, will see if I can find another way to do it (the @Q
is needed to quote the parameter).
@derschatta okay, that should be fixed now