View PHP folder on windows

I am writing a simple PHP script to look at a folder and its subfolders for any changes (new files, changes, deletes), and then perform an action.

I ran this script from the command line on Windows using php -f script.php.

I was looking for a way to view folders on Windows with PHP bindings. Something like inotify or gamin for windows would be nice.

The answer to this question mentions FindFirstChangeNotification, but I could not find PHP bindings for it.

Are there libraries / software for viewing a folder / file system in windows with PHP bindings?

+3
source share
3 answers

In the end, I just wrote a simple function using RecursiveDirectoryIterator, which is called in an infinite loop.

, , true false.

, . , script 12 .

+1

inotify_add_watch PHP, ( , , ) . , FileSystemWatcher Windows.

+1

Ruby, watchr gem

, , , fire/directory script, , , .

autotest.rb:

#!/usr/bin/ruby

# Match all PHP files in your project directory
watch("<PROJECT_DIR_PATH>/(.*).<FILE_EXTENSION_PHP>") do |match|
  run_test %{<PROJECT_DIR_PATH>/Tests/#{match[1]}Test.php}
end

# Match all files in your Tests directory
watch("<PROJECT_DIR_PATH>/Tests/.*Test.php") do |match|
  run_test match[0]
end

# Run test if there are matches
def run_test(file)
  unless File.exist?(file)
    puts "#{file} does not exist"
    return
  end

  puts "Running #{file}"
  result = `phpunit #{file}`
  puts result
end

Thus, this wil matches all PHP or any other extension files and runs RegEx against the file name, and if there is a match, for example /Project/Tests/ClassNameTest.php, it will run the test, otherwise it just ends with massage. For convenience, you can configure this to send error messages to predefined emails.

-1
source

All Articles