Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function sets the values of any basic PHP directive. The Basic Mode section of cPanel's MultiPHP INI Editor interface (Home >> Software >> MultiPHP INI Editor) lists these directives.

Note:

This document only applies to systems that run EasyApache 4.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/LangPHP/php_ini_set_user_basic_directives?type=vhost&directive-1=allow_url_fopen%3A0&directive-2=upload_max_filesize%3A4M&vhost=clearly.com
 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Change the contents of a PHP directive.
$php_ini_set_user_basic_directives = $cpanel->uapi(
    'LangPHP', 'php_ini_set_user_basic_directives',
    array(
        'type'     => 'vhost', 
        'vhost'	   => 'clearly.com',
		'directive-1'  => 'allow_url_fopen:0'
		'directive-2'  => 'upload_max_filesize:4M'
		)
);

Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Change the contents of a PHP directive.
my $php_ini_set_user_basic_directives = $cpliveapi->uapi(
    'LangPHP', 'php_ini_set_user_basic_directives',
    (
        'type'     => 'vhost', 
        'vhost'	   => 'clearly.com',
		'directive-1'  => 'allow_url_fopen:0'
		'directive-2'  => 'upload_max_filesize:4M'
		)
);

Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Template Toolkit
<!-- Get a hash of the return data. -->
[% execute('LangPHP', 'php_ini_set_user_basic_directives', 
{ 
        'vhost' => 'clearly.com', 
        'directive-1' => 'allow_url_fopen:0', 
        'directive-2' => 'upload_max_filesize:4M', 
     } 
); 
%]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line
uapi --user=username LangPHP php_ini_set_user_basic_directives type=vhost directive-1=allow_url_fopen%3A0 directive-2=upload_max_filesize%3A4M vhost=clearly.com

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{
      "LangPHP":{
         "vhost":"clearly.com",
         "phpversion":"ea-php55",
         "type":"vhost",
         "path":"/home/allthethings/public_html/php.ini"
      }
   },
   "data":null
}

Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample

type

string

Required

The type of php.ini file.

Important:

If you set this parameter to vhost, you must also include the vhost parameter.   

  • home
  • vhost
vhost
directivestring

Required

The name of a PHP directive and its value.

Note:

To change the directive's value for multiple PHP directives, increment the parameter name. For example, to change three directives, use the directive-1directive-2 , and directive-3 parameters.

Any valid directive and value.

Note:

You must format values as  <directive>:<value>

allow_url_fopen:0

vhost

string

The name of a virtual host.

Important:

If the type value is vhost, you must use this parameter.  

A virtual host on the system.

 

clearly.com

Returns

This function only returns metadata.