Resource Watcher

http://laravel.com/

http://kejyun.github.io/Laravel-4-Docum ... roduction/
回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Resource Watcher

文章 yehlu »

https://github.com/jasonlewis/resource-watcher

config/app.php

代碼: 選擇全部

        JasonLewis\ResourceWatcher\Integration\LaravelServiceProvider::class,

代碼: 選擇全部

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use JasonLewis\ResourceWatcher\Watcher;

class WatchNewFile extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'WatchNewFile';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
/*
      $files = new \Illuminate\Filesystem\Filesystem;
      $tracker = new \JasonLewis\ResourceWatcher\Tracker;
      $watcher = new \JasonLewis\ResourceWatcher\Watcher($tracker, $files);
      $listener = $watcher->watch(public_path('jpg'));
*/
      $watcher = app('watcher');
      $listener = $watcher->watch(public_path('jpg'));
      $listener->create(function($resource, $path) {
          echo "{$path} has been created.".PHP_EOL;
      });
      $listener->modify(function($resource, $path) {
          echo "{$path} has been modified.".PHP_EOL;
      });
      $listener->delete(function($resource, $path) {
          echo "{$path} has been deleted.".PHP_EOL;
      });
      $watcher->start();
    }
}

回覆文章

回到「laravel」