Checking Joomla version >=3.8 via bash

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
jobst
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Sun Feb 15, 2009 1:49 am

Checking Joomla version >=3.8 via bash

Post by jobst » Thu Nov 02, 2017 1:15 am

Hi
I used to be able to check the current Joomla version <3.8 via bash quite easily:

Code: Select all

php -r 'define("JPATH_PLATFORM","TEST");require("SITEPATH/libraries/cms/version/version.php");$version=new JVersion;echo $version->getShortVersion();'
Changing this to the new version.php file and changing class name

Code: Select all

php -r 'define("JPATH_PLATFORM","TEST");require("SITEPATH/libraries/src/Version.php");$version=new Version;echo $version->getShortVersion();'
yields an error

Code: Select all

 PHP Fatal error:  Class 'Version' not found in Command line code on line 1
Note: there is nothing wrong with the path, when I do an "ls SITEPATH/libraries/src/Version.php" there is no error. Also note I changed to "$version=new JVersion;" still the same error.

What am I doing wrong?
thanks
Last edited by imanickam on Thu Nov 02, 2017 3:38 am, edited 1 time in total.
Reason: Moved the topic from the forum Administration Joomla! 3.x to the forum Joomla! 3.x Coding

deleted user

Re: Checking Joomla version >=3.8 via bash

Post by deleted user » Thu Nov 02, 2017 12:18 pm

All classes in the libraries/src directory use PHP namespaces. So the class name is not just "Version". It is actually "Joomla\CMS\Version" (a combination of the "namespace" line in the file plus the class name).

jobst
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Sun Feb 15, 2009 1:49 am

Re: Checking Joomla version >=3.8 via bash

Post by jobst » Fri Nov 24, 2017 8:19 am

mbabker wrote:All classes in the libraries/src directory use PHP namespaces. So the class name is not just "Version". It is actually "Joomla\CMS\Version" (a combination of the "namespace" line in the file plus the class name).
Sorry, I sort off understand but this doesn't help me.
Not sure how to implement this in my code ...

Jobst

deleted user

Re: Checking Joomla version >=3.8 via bash

Post by deleted user » Fri Nov 24, 2017 6:30 pm

Use this:

Code: Select all

$version=new Joomla\CMS\Version;


Locked

Return to “Joomla! 3.x Coding”