TransWikia.com

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!

Ask a Question

Get help from others!

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