本文整理汇总了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;
});
}