Giới thiệu hàm rmdir sucks trong Drupal 8

Giới thiệu hàm rmdir sucks trong Drupal 8

Drupal 8 & Composer

>> Nhìn lại các phiên bản Versioning trong Drupal

During my work with Drupal 8 & Composer I created a PHP scrip that runs after Composer’s autoload dump. This does many things, such as setup settings.php, move some files and setup a local vagrant environment. As part of the Composer process for Drupal I end up with two vendor directories (long story) so I wanted to add something to this PHP script to delete the vendor directory. The obvious choice is rmdir, but it doesn’t work recursively, which is when I found the example below.

function rrmdir($dir) {
  foreach(glob($dir . '/{,.}*', GLOB_BRACE) as $file) {
    if(is_dir($file)) rrmdir($file); else unlink($file);
  } rmdir($dir);
}

You’ll notice this is looking through all directories, all sub-directories, ell sub-sub-directories, etc. This seemed to work well until I hit the following error:

glob(): Pattern exceeds the maximum allowed length of 1024 characters

This is the point I gave up, decided I had beter thing to procrastinate over and wen’t with passthrucontaining rm -rfto delete the duplicate vendor directory.

Bạn thấy bài viết này như thế nào?: 
Average: 5 (1 vote)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Tiện ích gỡ bỏ Timeline mới - Liệu có hiệu quả?

Tiện ích gỡ bỏ Timeline mới - Liệu có hiệu quả?

Phần mở rộng Timeline Remove mới cho trình duyệt có thể sẽ giúp bạn nói lời từ biệt với Timeline. Nhưng cẩn thận!

Drupalfund giúp get Tess to Drupalcon 2014 tại Austin!

Drupalfund giúp get Tess to Drupalcon 2014 tại Austin!

Flag module 8.x will have the benefit of uncovering bugs in Drupal 8 early so they can be fixed before D8 is released.

Android

Tương lai của Adobe và sự thất bại của Flash

Một kịch bản khó có thể tưởng tượng là Adobe đã từ bỏ cung cấp Flash Player dành cho các thiết bị di động. Vừa qua, Adobe đã lặng lẽ gỡ bỏ hoàn toàn ứng dụng Flash trên Google Play Store. Đây là một dấu hiệu khẳng định Flash đã thừa nhận thất bại và chính thức bị “khai tử”.

Công ty diệt chuột T&C

 

Diet con trung