<?php /** * Cache utilities */ Shell::alias('clearCache', function () { return Shell::sequence(Shell::rm('-rf', APP_DIR . '/cache/*'), Shell::mkdir(APP_DIR . '/cache/objects', APP_DIR . '/cache/views')); }); CLI::on('cache :action', function ($action) { switch ($action) { case 'clear': Shell::clearCache()->run(); break; default: echo "Cache utilities.", PHP_EOL; echo "- Available actions: clear", PHP_EOL; break; } });
public function test_mkdir() { // Will create sub-directory based on file name in /tmp $path = '/tmp/' . __CLASS__; try { $shell = new Shell(); $success = $shell->mkdir($path, 0777, true); $this->assertTrue($success, "Could not mkdir {$path}"); $this->assertTrue(is_dir($path)); $failure = @$shell->mkdir($path, 0777, true); $this->assertFalse($failure); @rmdir($path); // Clean up } catch (\Exception $e) { @rmdir($path); // Clean up throw $e; } }