PHP Modules

4 posts / 0 new
Last post
#1 Tue, 03/28/2017 - 16:06
volk

PHP Modules

I know, the software is PERL but is there some way to add PHP code or create a module that can execute PHP from inside the Webmin/Virtualmin/Cloudmin UI? Of course, executing the PHP file from PERL is possible but that is not elegant in anyway. The reason I ask this is because most developers I know are PHP ones and know nothing about Perl.

While they could potentially learn Perl, I don’t expect many users to learn a new coding language just to make some quick tweaks or changes. It would be nice to have some sort of module that can run PHP separated from the rest of the modules of course. Then you could use the API in the code to run common actions but for the user it would feel just like another regular interface inside the control panel or module. This would also speed up the integrations with other softwares.

Tue, 03/28/2017 - 17:41
Joe
Joe's picture

There's been a couple of attempts to make a PHP version of web-lib (which is the core Webmin library and sort of standardizes how pieces integrate), over the years. But, I'd probably recommend using the Virtualmin remote API or command line API, if at all possible, which can be done easily from PHP (or any language with an HTTP request library or a way to run local commands; using the remote API is recommended, since you would have the option to run your integrated apps on other systems and have them interact over the network).

I've personally been working on getting JSON APIs into Virtualmin, which would open it up to integrating in ways lots of modern devs are familiar with (a REST API with JSON data structures). That'd be the right way forward, I think, rather than picking one language and implementing a bunch of specific code for it to work with Virtualmin. If we had good JSON/REST APIs (and maybe GraphQL for some data structures), we'd be in a much nicer place in terms of interop.

And, if you know PHP, you've probably got a halfway decent grasp of Perl. PHP was inspired by Perl (and the very early versions were even built with Perl) and has a lot of similarities. PHP was not an option when Webmin started 20 years ago. ;-)

--

Check out the forum guidelines!

Tue, 03/28/2017 - 22:49
volk

Ah no, I don’t want Virtualmin to be PHP. I think one of the advantages it actually has is that it’s developed on Perl (even when some sites comparing control panels mention it wrongly as being developed with PHP).

For some strange reason, I always have the impression the same things in Perl are faster than exactly the same stuff in PHP. Maybe it’s just me or my mind playing tricks on me over the years, but I do thing that Virtualmin is so fast because its Perl or maybe it’s because Perl developers tend to be better than newbie PHP ones (me included). Or just because I always loved Perl as my first script language I ever learned.

I thing Perl probably adds some extra security vs PHP today. Not because it’s safer, that would be rubbish as I’m sure you can potentially execute similar flaws and injections to the code but for the fact that most attackers are very good at exploiting PHP apps today and less tools try to do it with Perl. Like the false sense of security, you could say with Windows Phone is more secure than Android because nobody is using it :)

I like Perl. And while I’m not an expert I may take my rusty Perl books out again just to benefit from writing something for Virtualmin. With the years I replaced Perl with PHP for most things, not because I disliked Perl but because everything is PHP today and so software, documentation and just general code is easier to find. It’s actually rare to see a web server software build in something else, its either PHP or Python.

I don’t want to run PHP inside the Virtualmin code, that would certainly be a bad idea running it as root….like most Virtualmin scripts already do. But just use the API like you mentioned but instead of having to setup an external server to the Virtualmin server where the PHP interpreter is executed have a way to run it build in with the same internal server.

Example, if you want to add an extra piece of code into the side menu that triggers a PHP page/module, this will probably cause all kind of security problems right now, unless its running as Virtualmin or inside it. If you are running it externally then you don’t need to log into Virtuamin in the first place. The idea is to extend what someone can do and make it feel as a natural extension of the control panel. For example, if someone wants to build a module service into Virtualmin that does something he needs to create a Perl module. But if they only know PHP, maybe a special module that wraps PHP from an allowed domain inside that server (that has a PHP interpreter and server running) could manually be allowed to execute Virtualmin data or requests (denying any other public requests but only accept them from inside logged Virtualmin users). I’m not sure to be honest. I just an idea to make it simpler for PHP developers that want to build things for the software.

Personally, I will just use Perl but it would be great if you already have code you can re-use. This would be for people that want to extend the control panel for their own use or customers, in no way I’m referring to push or mix code into the official software.

Thu, 02/28/2019 - 09:15
wilburunion

For tothers who find their way here to save time searching elsewhere see https://www.virtualmin.com/comment/740751#comment-740751 AND directly => https://www.virtualmin.com/documentation/developer/http which explains how to manage Virtualmin servers, users, databases and other features remotely from other programs. AND it has a PHP example

Centos7

Topic locked