API function server_get_php_versions

Discussion in 'General' started by AzraelAkuma, Nov 5, 2023.

  1. AzraelAkuma

    AzraelAkuma New Member

    Hi,
    I've been using ISP Config API with Ansible for a while now, and it's quite OK. Unfortunately documentation is not that great. I want to set PHP version for web site i create, but there's no such parameter in the documentation of "sites_web_domain_add" function :(. I found out that the parameter i need to set is called "server_php_id".
    I assume i need to get that ID using "server_get_php_versions". The documentation looks like this:
    Code:
    server_get_php_versions($session_id, $server_id, $php);
    
    Description:
    Returns the available PHP versions of the given server.
    
    Input Variables:
    $session_id, $server_id, $php
    
    Output:
    Returns an array with the available PHP versions.
    what is $php input parameter ?
    If i don't provide it i get an empty response.
    Thanx
     
    Last edited: Nov 6, 2023
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    $php would be either "php-fpm", "fast-cgi" or "hhvm" (only available if webserver is nginx).
     
    ahrasis likes this.
  3. AzraelAkuma

    AzraelAkuma New Member

    I get output like this
    Code:
        "resp": [
                "PHP 5.6:/etc/init.d/php5.6-fpm:/etc/php/5.6/fpm:/etc/php/5.6/fpm/pool.d",
                "PHP 7.0:/etc/init.d/php7.0-fpm:/etc/php/7.0/fpm:/etc/php/7.0/fpm/pool.d",
                "PHP 7.4:/etc/init.d/php7.4-fpm:/etc/php/7.4/fpm:/etc/php/7.4/fpm/pool.d",
                "PHP 8.0:/etc/init.d/php8.0-fpm:/etc/php/8.0/fpm:/etc/php/8.0/fpm/pool.d",
                "PHP 8.1:/etc/init.d/php8.1-fpm:/etc/php/8.1/fpm:/etc/php/8.1/fpm/pool.d"
            ]
    I need to get possible values of parameter
    Code:
     server_php_id 
    for sites_web_domain_add.
    How can i get that ?
    Is there any other way to set desired PHP version while creating the site via REST ?
     
    Last edited: Nov 10, 2023
  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Why don't you get the ID's from the database and put those in your code, e.g.
    Code:
    switch ($phpVersion) {
    case "7.4":
       $id = "1";
       break;
    case "8.0.:
       $id = "2"
       break;
    }
    
     
    ahrasis likes this.

Share This Page