本文整理匯總了PHP中Illuminate\Filesystem\Filesystem::macro方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filesystem::macro方法的具體用法?PHP Filesystem::macro怎麽用?PHP Filesystem::macro使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::macro方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filesystem
public static function filesystem()
{
$filesystem = new Filesystem();
Filesystem::macro('makeWritableByAll', (new ClosureFactory())->makeWritableByAll());
Filesystem::macro('isWritableByAll', (new ClosureFactory())->isWritableByAll());
return $filesystem;
}
示例2: macro
/**
* Register a custom macro.
*
* @param string $name
* @param callable $macro
* @return void
* @static
*/
public static function macro($name, $macro)
{
\Illuminate\Filesystem\Filesystem::macro($name, $macro);
}
示例3: Dotenv
<?php
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} else {
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require __DIR__ . '/../vendor/autoload.php';
} else {
require __DIR__ . '/../../../vendor/autoload.php';
}
}
use Dotenv\Dotenv;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Cache\FileStore;
use Illuminate\Cache\Repository as IlluminateCache;
use Work\Cache\Cache;
(new Dotenv(getenv('HOME'), '.workrc'))->load();
Filesystem::macro('touch', function ($filename) {
$this->append($filename, '');
});
if ((new Filesystem())->exists('.work')) {
(new Dotenv(getcwd(), '.work'))->load();
}
$filestore = new FileStore(new Filesystem(), getenv('CACHE'));
Cache::setCacheRepository(new IlluminateCache($filestore));
示例4: function
<?php
namespace Propaganistas\LaravelHelperMacros\Macros;
use Illuminate\Filesystem\Filesystem;
if (!Filesystem::hasMacro('globRecursive')) {
/**
* Recursively find pathnames matching a pattern.
*
* @param string $pattern
* @param int $flags
* @return array
*/
Filesystem::macro('globRecursive', function ($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
$files = array_merge($files, Filesystem::globRecursive($dir . '/' . basename($pattern), $flags));
}
return $files;
});
}