SOLVED Programming language to create cPanel plugin?

Aug 31, 2019
5
2
3
Canada
cPanel Access Level
Root Administrator
I've reviewed some of the documentation provided but I wanted to get feedback or recommendations from users within the community.

What is the best/recommended programming language to build a cPanel plugin?

The plugin will allow users to install and manage WordPress installations. I know this functionality already exists within cPanel, but this is for a custom, 3rd-party project.
 

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
34
10
83
Houston, TX
cPanel Access Level
Root Administrator
Twitter
Hi hansdesjarlais,

I hope some plugin developers can weigh in on your question as well, but I'll share my thoughts.

Plugins can be written in any language compatible with the Linux shell, but what I can recommend is either Perl or PHP, or a combination of both, as it really depends on how much you're working with cPanel vs. working with WordPress. Perl will make it is easier to access certain cPanel functionality as it's written in Perl and the same can be said for PHP and WordPress.
 
  • Like
Reactions: cPanelMichael
Aug 31, 2019
5
2
3
Canada
cPanel Access Level
Root Administrator
Hi hansdesjarlais,

I hope some plugin developers can weigh in on your question as well, but I'll share my thoughts.

Plugins can be written in any language compatible with the Linux shell, but what I can recommend is either Perl or PHP, or a combination of both, as it really depends on how much you're working with cPanel vs. working with WordPress. Perl will make it is easier to access certain cPanel functionality as it's written in Perl and the same can be said for PHP and WordPress.
Thank for the response @cPanelTJ

I do have 2 more questions for you.

#1 - What is the best way to setup a cpanel plugin development environment? I was thinking of setting up a small Linode instance with a LAMP stack and then installing cPanel. Do you recommend anything better or easier?

#2 - I watched one of your cPanel Youtube videos explaining how to work with the API. For my purposes, should I be working with API1 or API2?
 

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
34
10
83
Houston, TX
cPanel Access Level
Root Administrator
Twitter
Hi @hansdesjarlais,

#1 - If you don't have one already, definitely grab a developer's license: Developer License Application. Regarding the environment, it really depends on the application you're trying to develop and what all it may interact. Mostly all cPanel&WHM servers will be running on a version of CentOS. I really don't have too much of a preference, but maybe other external developers can weigh in here. In the end you'll want to make sure your application will install and run as expected on a realistic cPanel&WHM environment.

#2 - For cPanel user operations, UAPI is the recommended API to use. For WHM actions, WHM API 1 is the recommended API to use. We are currently working on consolidating our cPanel APIs so that all functionality is supported in UAPI. The majority of cPanel API 1 functionality will be ported to UAPI in version 86, and project is planned for completion in version 88. If you need specific functionality within UAPI and you don't see it currently, let me know and I can give you an accurate update on when it would be available and/or a recommendation to use instead.
 
Aug 31, 2019
5
2
3
Canada
cPanel Access Level
Root Administrator
Hi @cPanelTJ

Thanks for the responses.

I have setup a dev environment and managed to get my custom plugin installed.

I have a question about how to enqueue Javascript/jQuery into my files.

I see that paper_lantern is using BootStrap v3.1.1, however my custom Jquery code isn't working unless I link in an external copy.

This is how I added it at the bottom of my index.live.php file.

PHP:
<!-- SCRIPTS -->
<!-- SCRIPTS -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!-- Bootstrap 3.1.1 Latest compiled and minified JavaScript -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- OCWPI Script -->
<script type="text/javascript" src="script.js"></script>

<?php
  print $cpanel->footer(); // Add the footer.
  $cpanel->end(); // Disconnect from cPanel - only do this once.
?>
Can you help clarify how I can do this without using an external source?
 

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
34
10
83
Houston, TX
cPanel Access Level
Root Administrator
Twitter
@hansdesjarlais, I had to do some digging on this one and ask a few of my team's developers. Would something like this solve your problem?

PHP:
<?php
// Instantiate the CPANEL object.
require_once "/usr/local/cpanel/php/cpanel.php";
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

print $cpanel->header('Testing output');
print 'some stuff';
?>

<!-- SCRIPTS -->
<script type='text/javascript' src='libraries/jquery/3.2.0/jquery-3.2.0.js'></script>
<script type='text/javascript' src='libraries/bootstrap/optimized/js/bootstrap.min.js'></script>

<?php
print $cpanel->footer();
$cpanel->end(); // Disconnect from cPanel - only do this once.
?>
This is under the assumption that the file is within paper_lantern of course.
 
Aug 31, 2019
5
2
3
Canada
cPanel Access Level
Root Administrator
Hi @cPanelTJ

Ok, so that worked but with a slight change.

PHP:
<!-- SCRIPTS -->
<script type='text/javascript' src='../libraries/jquery/3.2.0/jquery-3.2.0.js'></script>
<script type='text/javascript' src='../libraries/bootstrap/optimized/js/bootstrap.min.js'></script>
 
  • Like
Reactions: cPanelTJ

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
34
10
83
Houston, TX
cPanel Access Level
Root Administrator
Twitter
Hi @cPanelTJ

Ok, so that worked but with a slight change.

PHP:
<!-- SCRIPTS -->
<script type='text/javascript' src='../libraries/jquery/3.2.0/jquery-3.2.0.js'></script>
<script type='text/javascript' src='../libraries/bootstrap/optimized/js/bootstrap.min.js'></script>
Great to hear!