All Products
Search
Document Center

Function Compute:Add or remove built-in PHP extensions

Last Updated:Jun 20, 2026

The Function Compute PHP runtime environment includes several common built-in extensions. You can also customize your environment by adding or removing these extensions.

This topic uses the protobuf built-in extension to demonstrate how to remove an extension. For a list of built-in extensions supported by the Function Compute PHP runtime environment, see PHP built-in extensions.

  1. In the same directory as your function's entry file, create a directory named extension. The directory structure is as follows:

    .
    |____extension
    | |____my_ext.ini
    |____index.php
  2. Edit the my_ext.ini file to comment out the protobuf extension.

    You can add other extensions or comment out unnecessary ones to optimize startup speed. For example:

    extension=session.so
    extension=ftp.so
    extension=shmop.so
    extension=bcmath.so
    extension=gettext.so
    extension=pcntl.so
    extension=simplexml.so
    extension=xmlreader.so
    extension=bz2.so
    extension=gmp.so
    extension=pdo.so
    extension=soap.so
    extension=xmlrpc.so
    extension=calendar.so
    extension=iconv.so
    extension=pdo_mysql.so
    extension=sockets.so
    extension=xmlwriter.so
    extension=ctype.so
    extension=imagick.so
    extension=phar.so
    extension=sysvmsg.so
    extension=dom.so
    extension=json.so
    extension=posix.so
    extension=sysvsem.so
    extension=exif.so
    extension=zip.so
    extension=memcached.so
    extension=mbstring.so
    ;extension=protobuf.so
    extension=sysvshm.so
    extension=fileinfo.so
    extension=mysqli.so
    extension=redis.so
    extension=tokenizer.so
    extension=zip.so
    extension=memcached.so
    zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/opcache.so
    zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
  3. Create a function using a code package with the preceding directory structure. For more information, see Create a function.

  4. Set the environment variables for the function. By pointing PHP_INI_SCAN_DIR to your custom configuration directory, you ensure the PHP runtime environment does not load the protobuf extension. In the function's Environment Variables configuration, set the PHP_INI_SCAN_DIR variable to /code/extension.