Can't get a task to work from CLI

Joomla Asked by TC0072 on September 5, 2021

I’ve got a custom component I’ve written which has a task that needs to be run every evening.
I’m using JApplicationCli but I can’t get it to work.

From searching on the web I’ve found a suggestion to use renderComponent like this:

class myCli extends JApplicationCli
    public function doExecute()
        $app = JFactory::getApplication('site');
        $app->input->set('task', 'myController.myTask');
        $component = JoomlaCMSComponentComponentHelper::renderComponent('com_myComponent');

The problem I’m having is when my code tries to get an instance of another component it gets back false:
$vmuser = JModelLegacy::getInstance('User','VirtueMartModel');

This works when I run it as a normal web request but not from the cli.

Add your own answers!

Related Questions

Add field to menu settings to output open graph image

1  Asked on December 30, 2021 by mano-meter


Edited css not updated in XAMPP

1  Asked on December 9, 2021 by advait-varma


Update from 3.9.x to 4.x

2  Asked on November 27, 2021 by lovntola


Other files overriding my template css with bootstrap?

1  Asked on November 19, 2021 by matthiasdunkel


Javascript accordion with anchors for joomla

1  Asked on November 5, 2021 by fruit_alchemist


Cannot Connect To MSSQL Server

3  Asked on September 5, 2021 by jamesmandatory


PlotALOT RSForm Query showing only one result

1  Asked on September 5, 2021 by gart


Getting module parameters in AJAX call using module id

1  Asked on September 5, 2021 by user1616338


Pop up AcyMailing subscription form

1  Asked on September 5, 2021 by ygiorgos


Override 3d party extension plugin method

0  Asked on September 5, 2021 by dmitry-zar


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP