Checking Joomla version >=3.8 via bash

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

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
jobst
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Feb 15, 2009 1:49 am

Checking Joomla version >=3.8 via bash

Postby 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

mbabker
Joomla! Hero
Joomla! Hero
Posts: 2176
Joined: Sun Feb 28, 2010 8:26 pm

Re: Checking Joomla version >=3.8 via bash

Postby mbabker » 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).
So long and thanks for all the fish.

Manually updating Joomla? See https://gist.github.com/mbabker/d7bfb4e1e2fbc6b7815a733607f89281

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

Re: Checking Joomla version >=3.8 via bash

Postby 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

mbabker
Joomla! Hero
Joomla! Hero
Posts: 2176
Joined: Sun Feb 28, 2010 8:26 pm

Re: Checking Joomla version >=3.8 via bash

Postby mbabker » Fri Nov 24, 2017 6:30 pm

Use this:

Code: Select all

$version=new Joomla\CMS\Version;
So long and thanks for all the fish.

Manually updating Joomla? See https://gist.github.com/mbabker/d7bfb4e1e2fbc6b7815a733607f89281


Return to “Joomla! 3.x Coding”

Who is online

Users browsing this forum: No registered users and 1 guest