dev in Suite vs CE?

Hey! If I’m creating a custom module that uses the same code for Suite and CE…how can I tell if I am in Suite or CE? My initial thought is to use the config for suitecrm_version, something like:

global $sugar_config;
if (!empty($sugar_config[’suitecrm_version’]))
// run suite code
// run ce code

Any thoughts or best practices here? Thanks for any suggestions!

check to see if the suitecrm_version.php file exists in the root of your instance.

if so the your using suite. otherwise you are using sugar.

Thanks for that! Can you advise why it’s better to make that call than to use the config? I was thinking the config would be less intensive?

It makes little difference in terms of performance or in best practices.

Checking for the suitecrm_version.php file is functionally agnostic. it doesn’t require an entrypoint to pre-fetch the dependencies and set up the SugarApplication class object.

It is particularly useful when you are creating a php script outside of SuiteCRM. However to get the version of suitecrm using an external script: you will need to set up a fake ‘sugarEntry’ global variable, require the file and then use $suitecrm_version variable get the version your are working with.

In your case using the $sugar_config global makes sense because the SugarApplication will have already setup the globals for you. But the solution I gave is the most robust way to check to see if you are using SuiteCRM. Getting the version depends on the context of your code. As version handling, is left up to you to deal with.

You may just explode the version number to get the major, minor, patched numbers.

1 Like

Also there is little architectural difference between SuiteCRM and Sugar CE. It’s the modules that are different. So that if you intend to use a module that only exists in SuiteCRM then it would be a better way to check the $moduleList and the $beanList instead.

I appreciate the deep answer and explanation! Thanks.