Hello,
can someone please tell me what I'm doing wrong.
I had CliApplication scripts in Joomla3 and now I want to make them Joomla4/5 compatible.
I already tried following this method https://docs.joomla.org/J4.x:Writing_A_CLI_Application and also tried following this one https://www.dionysopoulos.me/book/com-cli.html.
But whenever I call php cli/joomla.php list I don't see my command in the list.
Do I have to do something else, for example clear a cache?
Writing A CLI Application
Moderators: ooffick, General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
-
- Joomla! Fledgling
- Posts: 4
- Joined: Sun Nov 28, 2010 4:32 pm
- ceford
- Joomla! Hero
- Posts: 2677
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: Writing A CLI Application
Did you enable your plugin? Here is another example to look at:
https://docs.joomla.org/J4.x:CLI_example_-_Onoffbydate
https://docs.joomla.org/J4.x:CLI_example_-_Onoffbydate
-
- Joomla! Fledgling
- Posts: 4
- Joined: Sun Nov 28, 2010 4:32 pm
Re: Writing A CLI Application
I have now installed and activated the plugin https://github.com/ceford/j4xdemos-plg-onoffbydate but the php cli/joomla.php list shows no onoffbydate.
Do I need to do anything other than install and activate the plugin?
Do I need to do anything other than install and activate the plugin?
- ceford
- Joomla! Hero
- Posts: 2677
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: Writing A CLI Application
I just downloaded the zip file and installed it via System / Install / Extensions and it worked fine. I see it in the list with this command from the cli folder (using a terminal):
And this:
I did not actually toggle a module because you said you do not see the command in the list.
Code: Select all
ceford@cliff cli % php joomla.php
finder
finder:index Purges and rebuild the index
onoffbydate
onoffbydate:action Called by cron to set the enabled state of a module.
scheduler
scheduler:list List all scheduled tasks
Code: Select all
ceford@cliff cli % php joomla.php --help onoffbydate:action
Usage:
onoffbydate:action <action> <module_id>
Arguments:
action name of action
module_id module id
Options:
--live-site[=LIVE-SITE] The URL to your site, e.g. https://www.example.com
-h, --help Display the help information
-q, --quiet Flag indicating that all output should be silenced
-V, --version Displays the application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Flag to disable interacting with the user
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
onoffbydate:action Toggles module Enabled/Disabled state
Usage: php joomla.php onoffbydate:action action_id module_id
where action_id is one of winter or weekend
-
- Joomla! Fledgling
- Posts: 4
- Joined: Sun Nov 28, 2010 4:32 pm
Re: Writing A CLI Application
Thanks, but the command really isn't in the list.
What version do you see when you type php joomla.php -V?
For me, Joomla! 4.2.6 displayed.
What version do you see when you type php joomla.php -V?
For me, Joomla! 4.2.6 displayed.
- ceford
- Joomla! Hero
- Posts: 2677
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: Writing A CLI Application
I see Joomla! 4.2.9. I think you should double check that the plugin is enabled. If I disable the plugin the command disappears from the list.