A partir de Joomla 3.8, les classes Jxxx sont renommées.

Le loader a été modifié pour changer les noms dynamiquement et conserver la compatibilité, ceci jusqu’à Joomla 4, et certainement même Joomla 5.

Voici donc les changements à faire progressivement.

L’intérêt est que l'IDE que vous utilisez soit capable de faire la liaison avec la classe utilisée, par exemple pour conserver la complétion automatique.

Si vous développez, ne mettez plus le J quand vous appelez la classe et dans ce cas ajoutez juste le use, sans le as.

Si vos développements sont déjà fait (et donc que vous appelez les classe avec le J devant, déclarez la classe avec les use... as J....

Ancienne classe Devient Use Observation ou emplacement
JAccessRules Joomla\CMS\Access\Rules use Joomla\CMS\Access\Rules as JAccessRules; /libraries/src/Access/Rules.php
JApplicationHelper Joomla\CMS\Application\ApplicationHelper use Joomla\CMS\Application\ApplicationHelper as JApplicationHelper;  
JArrayHelper ArrayHelper Use Joomla\Utilities\ArrayHelper; deprecated 4.0 Use Joomla\Utilities\ArrayHelper instead
/librairies/vendor/Joomla/utilities/src/ArrayHelper.php
JBrowser Joomla\CMS\Environment\Browser use Joomla\CMS\Environment\Browser as JBrowser; /libraries/src/Environment/Browser.php
 JCategories  Joomla\CMS\Categories\Categories  use Joomla\CMS\Categories\Categories as JCategories;  /libraries/src/Categories/Categories.php
JCategoryNode  Joomla\CMS\Categories\CategoryNode  use Joomla\CMS\Categories\CategoryNode as JCategoryNode; /libraries/src/Categories/CategoryNode.php
JClientHelper Joomla\CMS\Client\ClientHelper use Joomla\CMS\Client\ClientHelper as JClientHelper;  
JComponentHelper Joomla\CMS\Component\ComponentHelper  use Joomla\CMS\Component\ComponentHelper as JComponentHelper;  
JComponentRouterRulesInterface Joomla\CMS\Component\Router\Rules\RulesInterface use Joomla\CMS\Component\Router\Rules\RulesInterface as JComponentRouterRulesInterface; /libraries/src/Component/Router/Rules/RulesInterface.php
JComponentRouterView Joomla\CMS\Component\Router\RouterView use Joomla\CMS\Component\Router\RouterView as JComponentRouterView; /libraries/src/Component/Router/RouterView.php
JControllerAdmin Joomla\CMS\MVC\Controller\AdminController use Joomla\CMS\MVC\Controller\AdminController as JControllerAdmin;  
JControllerForm Joomla\CMS\MVC\Controller\FormController use Joomla\CMS\MVC\Controller\FormController as JControllerForm;  
JControllerLegacy Joomla\CMS\MVC\Controller\BaseController  use Joomla\CMS\MVC\Controller\BaseController as JControllerLegacy;  
JDate Joomla\CMS\Date\Date  use Joomla\CMS\Date\Date as JDate;  
JDataBaseDriver     /librairies/joomla/database/driver
JFactory Joomla\CMS\Factory  use Joomla\CMS\Factory as JFactory;  
JFilterInput Joomla\CMS\Filter\InputFilter  use Joomla\CMS\Filter\InputFilter as JFilterInput;  
JFilterOutput Joomla\CMS\Filter\OutputFilter  use Joomla\CMS\Filter\OutputFilter as JFilterOutput;  /libraries/src/Filter/OutputFilter.php
JForm Joomla\CMS\Form\Form  use Joomla\CMS\Form\Form as JForm;  
JFormField Joomla\CMS\Form\FormField  use Joomla\CMS\Form\FormField as JFormField; /libraries/src/Form/FormField.php
JformHelper Joomla\CMS\Form\FormHelper    
JFormRule Joomla\CMS\Form\FormRule  use Joomla\CMS\Form\FormRule as JFormRule;  
JHelperContent Joomla\CMS\Helper\ContentHelper  use Joomla\CMS\Helper\ContentHelper as JHelperContent;  
JHelperTags Joomla\CMS\Helper\Tagshelper  use Joomla\CMS\Helper\Tagshelper as JHelperTags;  
JHtml Joomla\CMS\HTML\HTMLHelper  use Joomla\CMS\HTML\HTMLHelper as JHtml;  
JInstallerHelper Joomla\CMS\Installer\InstallerHelper  use Joomla\CMS\Installer\InstallerHelper as JInstallerHelper;  
JLanguageAssociations  Joomla\CMS\Language\Associations  use Joomla\CMS\Language\Associations as JLanguageAssociations;  /librairies/src/Language/Associations.php
JLanguageHelper Joomla\CMS\Language\LanguageHelper  use Joomla\CMS\Language\LanguageHelper as JLanguageHelper; /librairies/src/Language/LanguageHelper.php
JLanguageMultilang Joomla\CMS\Language\Multilanguage use Joomla\CMS\Language\Multilanguage as JLanguageMultilang;  /librairies/src/Language/Multilanguage.php
JLayoutFile  Joomla\CMS\Layout\BaseLayout  use Joomla\CMS\Layout\BaseLayout as JLayoutFile;  /librairies/src/Layout/FileLayout.php
JLayoutHelper Joomla\CMS\Layout\LayoutHelper  use Joomla\CMS\Layout\LayoutHelper as JLayoutHelper;  
JLoader      
JLog Joomla\CMS\Log\Log  use \Joomla\CMS\Log\Log as JLog;  
JMailer Joomla\CMS\Mail use Joomla\CMS\Mail as JMailer; utiliser \Joomla\CMS\Factory::getMailer() pour obtenir la classe
JModelAdmin Joomla\CMS\MVC\Model\AdminModel use Joomla\CMS\MVC\Model\AdminModel as JModelAdmin;  
JModelForm \Joomla\CMS\MVC\Model\FormModel use \Joomla\CMS\MVC\Model\FormModel as JModelForm;  
JModelItem Joomla\CMS\MVC\Model\ItemModel use Joomla\CMS\MVC\Model\ItemModel as JModelItem;  
JModelLegacy  Joomla\CMS\MVC\Model\BaseDatabaseModel  use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModelLegacy;  /libraries/src/MVC/Model/BaseDataBaseModel.php
JModelList Joomla\CMS\MVC\Model\ListModel  use Joomla\CMS\MVC\Model\ListModel as JModelList;  
JObject Joomla\CMS\Object\CMSObject use Joomla\CMS\Object\CMSObject as JObject /libraries/src/Object/CMSObject.php
JPagination  Joomla\CMS\Pagination\Pagination  use Joomla\CMS\Pagination\Pagination as JPagination;  /libraries/src/Pagination/Pagination.php
JPlugin Joomla\CMS\Plugin\CMSPlugin use Joomla\CMS\Plugin\CMSPlugin as JPlugin; /libraries/src/Plugin/CMSPlugin.php
JPluginHelper Joomla\CMS\Plugin\PluginHelper  use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;  
JRegistry  Joomla\Registry\Registry  use Joomla\Registry\Registry as JRegistry;  
JRoute Joomla\CMS\Router\Route  use Joomla\CMS\Router\Route as JRoute;  
JSession Joomla\CMS\Session\Session  use Joomla\CMS\Session\Session as JSession;  
JStringPunycode Joomla\CMS\String\PunycodeHelper  use Joomla\CMS\String\PunycodeHelper as JStringPunycode; /librairies/src/String/PunycodeHelper.php
JTable Joomla\CMS\Table\Table  use Joomla\CMS\Table\Table as JTable;  
JTableCategory Joomla\CMS\Table\Category use Joomla\CMS\Table\Category as JTableCategory;  
JText Joomla\CMS\Language\Text  use Joomla\CMS\Language\Text as JText;  
JToolbar Joomla\CMS\Toolbar\Toolbar  use Joomla\CMS\Toolbar\Toolbar as JToolbar;  
JToolbarHelper Joomla\CMS\Toolbar\ToolbarHelper  use Joomla\CMS\Toolbar\ToolbarHelper as JToolbarHelper;  
JUcmType  Joomla\CMS\UCM\UCMType   use Joomla\CMS\UCM\UCMType as JUcmType;  /librairies/src/UCM/UCMType.php
JUri Joomla\CMS\Uri\Uri use Joomla\CMS\Uri\Uri as JUri;  
JUser Joomla\CMS\User\User  use Joomla\CMS\User\User as JUser;  
JUserHelper Joomla\CMS\User\UserHelper  use Joomla\CMS\User\UserHelper as JUserHelper;  
JVersion Joomla\CMS\Version  use Joomla\CMS\Version as JVersion;  
JViewcategories  Joomla\CMS\MVC\View\CategoriesView  use Joomla\CMS\MVC\View\CategoriesView as JViewCategories;  /libraries/src/MVC/View/CategoriesView.php
JViewCategory  Joomla\CMS\MVC\View\CategoryView  use Joomla\CMS\MVC\View\CategoryView as JViewCategory;  /libraries/src/MVC/View/CategoryView.php
JViewLegacy  Joomla\CMS\MVC\View\HtmlView  use Joomla\CMS\MVC\View\HtmlView as JViewLegacy;  /libraries/src/MVC/View/HtmlView.php

Je compléterai ce tableau progressivement.

Donc 2 formules (exemple pour JFactory)  :

  • soit on remplace par exemple : JFactory::getApplication() par \Joomla\CMS\Factory::getApplication()
  • soit on place tout au début des scripts : use Joomla\CMS\Factory as JFactory;

Personnellement je préfere la 2ème formule.

En fait en execution le loader se débrouille et trouve les Classes.

C'est juste avec un IDE que l'IDE ne s'en sort par et vous avez des erreurs.
De plus vous perdez l'autocompletion, et la description des fonctions.

Voir aussi : /librairies/classmap.php

ordi-genie F-68800 THANN