I am trying to create a cron task for the search index in Joomla 4. The PHP file is also called, but an error occurs.

I created the cron tasks according to these instructions:

And it looks like this:

php -d memory_limit=512M httpdocs/cli/joomla.php finder:index

And this is the error:

Symfony\Component\ErrorHandler\Error\UndefinedFunctionError {#164
  #message: "Attempted to call function "simplexml_load_file" from namespace "Joomla\CMS\Language"."
  #code: 0
  #file: ".httpdocs/libraries/src/Language/LanguageHelper.php"
  #line: 614
  trace: {
    .httpdocs/libraries/src/Language/LanguageHelper.php:614 {
      › // Try to load the file
      › $xml = simplexml_load_file($path);
    .httpdocs/libraries/src/Language/LanguageHelper.php:516 { …}
    .httpdocs/libraries/src/Language/Language.php:203 { …}
    .httpdocs/libraries/src/Language/LanguageFactory.php:35 { …}
    .httpdocs/libraries/src/Language/CachingLanguageFactory.php:45 { …}
    .httpdocs/libraries/src/Service/Provider/Application.php:130 { …}
    .httpdocs/libraries/vendor/joomla/di/src/ContainerResource.php:176 { …}
    .httpdocs/libraries/vendor/joomla/di/src/Container.php:96 { …}
    .httpdocs/cli/joomla.php:75 { …}

Presumably this function is simply for security reasons (unfortunately I hadn't realised at first that different PHP installations are used within the provider's Cron Task UI).

Are there alternative ways to make the indexer work automatically?

  • 1
    It means XML is disabled on your PHP installation. Perhaps CLI/cron is using a different PHP installation or configuration than the web server. Ask your host.
    – Sharky
    Mar 19 at 9:44
  • My CRON jobs for Joomla CLI follow this format: /usr/local/bin/php /home/{account}/public_html/cli/joomla.php cache:clean -n -q You could look in Joomla Administrator under System > Information > System Information > PHP Information to see if SimpleXML is enabled.
    – Dan
    Mar 19 at 17:45
  • The file is found (the path is correct) and SimpleXML is also enabled. Mar 19 at 18:09
  • 2
    You can always just try running a little php script with just one line $xml=simplexml_load_file('filename of an xml file'); and see if that returns an error or not. Mar 20 at 21:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.