"Warning: file_exists(): open_basedir restriction in effect" when trying to install new modules on Drupal 8.x

If you are using shared hosting, service provider may restrict the right to access the top-level directory.

1.Modify the function mkdir as following at "/core/lib/Drupal/Core/File/FileSystem.php"

Unknown: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s) (solved)

If you are using vesta and facing this issue. You could follow these steps to solve your problem.

  1. You have to modify these two files. If the file {domain name}.com.httpd.ssl.conf don't exist, you can skip this file.
    vi /home/{user name}/conf/web/{domain name}.com.httpd.conf
    vi /home/{user name}/conf/web/{domain name}.com.httpd.ssl.conf
  2. Add "php_admin_value sys_temp_dir /home/{user name}/tmp" into these two files as below.

The code easy to zip files and directories in PHP

Sample Usage

//The value is the path of the file already exists.
//The key is the path in the zip file.

$files_to_zip = array(
        'home/file4.txt', // equal to 'home/file4.txt'=>'/home/file4.txt',
//if true, good; if false, zip creation failed
$result = easy_to_zip($files_to_zip,'my-archive.zip');


Answer command's questions by a command in PHP

  • When you use php to execute a command, the command has required you answer single question for complete the process.
    echo 'answer' | command
  • When you use php to execute a command, the command has required you answer multi questions for complete the process. Uses "\n" to separate each answer.
    printf 'answer1\nanswer2\nanswer3' | command

How to change and update database using hook_update_N in Drupal 8

  1. Create *.install file inside your module folder. If your module is named mymodule, the path of the *.install file should be in "/module/mymodule/mymodule.install".
  2. Impletment the hook_update_N function on the mymodule.install file. The character N is the version number of the update.
    • In Drupal 8, The first digital should be 8.
    • The second digital is the api version of the module.
    • The last two digitals is the serial number of the update.


Subscribe to Development in Drupal 8 and Drupal 7 RSS