本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::files方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::files方法的具体用法?PHP Filesystem::files怎么用?PHP Filesystem::files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::files方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
foreach ($this->files->files(storage_path() . '/views') as $file) {
$this->files->delete($file);
}
$this->info('Views deleted from cache');
}
示例2: importTranslations
public function importTranslations($replace = false)
{
$counter = 0;
foreach ($this->files->directories($this->app->langPath()) as $langPath) {
$locale = basename($langPath);
foreach ($this->files->files($langPath) as $file) {
$info = pathinfo($file);
$group = $info['filename'];
if (in_array($group, $this->config['exclude_groups'])) {
continue;
}
$translations = \Lang::getLoader()->load($locale, $group);
if ($translations && is_array($translations)) {
foreach (array_dot($translations) as $key => $value) {
$value = (string) $value;
$translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
// Check if the database is different then the files
$newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
if ($newStatus !== (int) $translation->status) {
$translation->status = $newStatus;
}
// Only replace when empty, or explicitly told so
if ($replace || !$translation->value) {
$translation->value = $value;
}
$translation->save();
$counter++;
}
}
}
}
return $counter;
}
示例3: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
foreach ($this->files->files(storage_path() . '/logs') as $file) {
$this->files->delete($file);
}
$this->info('Log files deleted from storage');
}
示例4: doNotOverwriteFile
/**
* Do not overwrite a migration file
*
* @access protected
* @param string $filePath
* @param string $name
* @return void
*/
protected function doNotOverwriteFile($filePath, $name)
{
foreach ($this->file->files($filePath) as $file) {
if (strpos($file, $name) !== false) {
throw new FileExistsException($file);
}
}
}
示例5: deleteFilesOlderThanMinutes
/**
* @param int $minutes
*
* @return \Illuminate\Support\Collection
*/
public function deleteFilesOlderThanMinutes(int $minutes) : Collection
{
$timeInPast = Carbon::now()->subMinutes($minutes);
return collect($this->filesystem->files($this->directory))->filter(function ($file) use($timeInPast) {
return Carbon::createFromTimestamp(filemtime($file))->lt($timeInPast);
})->each(function ($file) {
$this->filesystem->delete($file);
});
}
示例6: firstRound
/**
* First round
* @param $path
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function firstRound($path)
{
foreach ($this->file->files($path) as $file) {
//Extension .php
if (preg_match("|\\.php\$|", $file)) {
$this->handle($this->file->get($file));
}
}
}
示例7: getCatalogs
/**
* @return array
*/
public function getCatalogs()
{
$result = array();
foreach ($this->filesystem->directories($this->getLangDir()) as $langPath) {
foreach ($this->filesystem->files($langPath) as $file) {
$catalog = str_replace($langPath . '/', '', $file);
$catalog = preg_replace('/\\.php$/', '', $catalog);
$result[$catalog] = $catalog;
}
}
return array_keys($result);
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$countries = $this->files->directories($this->path);
$cities = [];
foreach ($countries as $countryDirectory) {
$states = $this->files->files($countryDirectory);
$country = $this->last(explode(DIRECTORY_SEPARATOR, $countryDirectory));
foreach ($states as $stateDirectory) {
list($state, $_) = explode('.', $this->last(explode(DIRECTORY_SEPARATOR, $stateDirectory)));
$data = $this->loader->load($country, $state, 'en');
foreach ($data as $key => $name) {
$cities[] = ['name' => $name, 'code' => "{$country} {$state} {$key}", 'state_id' => "{$country} {$state}"];
}
}
}
$cities = Collection::make($cities);
$hash = md5($cities->toJson());
if (!$this->option('force') && $hash === $this->hash) {
$this->line('No new city.');
return false;
}
$cityCodes = $cities->pluck('code');
$stateCodes = $cities->pluck('state_id')->unique();
$stateIds = Collection::make(DB::table($this->states)->whereIn('code', $stateCodes)->pluck('id', 'code'));
$cities = $cities->map(function ($item) use($stateIds) {
$item['state_id'] = $stateIds->get($item['state_id']);
return $item;
});
$existingCityIDs = Collection::make(DB::table($this->cities)->whereIn('code', $cityCodes)->pluck('id', 'code'));
$cities = $cities->map(function ($item) use($existingCityIDs) {
if ($existingCityIDs->has($item['code'])) {
$item['id'] = $existingCityIDs->get($item['code']);
}
return $item;
});
$cities = $cities->groupBy(function ($item) {
return array_has($item, 'id') ? 'update' : 'create';
});
DB::transaction(function () use($cities, $hash) {
$create = Collection::make($cities->get('create'));
$update = Collection::make($cities->get('update'));
foreach ($create->chunk(static::QUERY_LIMIT) as $entries) {
DB::table($this->cities)->insert($entries->toArray());
}
foreach ($update as $entries) {
DB::table($this->cities)->where('id', $entries['id'])->update($entries);
}
$this->line("{$create->count()} cities created. {$update->count()} cities updated.");
$this->files->put(storage_path(static::INSTALL_HISTORY), $hash);
});
return true;
}
示例9: migrate
/**
* Run package database migrations.
* Thanks http://stackoverflow.com/questions/27759301/setting-up-integration-tests-in-a-laravel-package
*
* @return void
*/
public function migrate()
{
$fileSystem = new Filesystem();
$classFinder = new ClassFinder();
$packageMigrations = $fileSystem->files(__DIR__ . "/../../src/Migrations");
$laravelMigrations = $fileSystem->files(__DIR__ . "/../../vendor/laravel/laravel/database/migrations");
$migrationFiles = array_merge($laravelMigrations, $packageMigrations);
foreach ($migrationFiles as $file) {
$fileSystem->requireOnce($file);
$migrationClass = $classFinder->findClass($file);
(new $migrationClass())->up();
}
}
示例10: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
\DB::statement('SET FOREIGN_KEY_CHECKS=0;');
foreach ($this->filesystem->files(__DIR__ . "/../../../../database/migrations") as $file) {
$this->filesystem->requireOnce($file);
$migrationClass = $this->classFinder->findClass($file);
$migration = new $migrationClass();
$migration->down();
$migration->up();
}
$this->info("Merx tables migrated.");
\DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
示例11: findAvailableTemplates
/**
* @param Theme $theme
*
* @return array
*/
public function findAvailableTemplates(Theme $theme)
{
$files = $this->filesystem->files($theme->getTemplateDirectory());
$templates = [];
if (is_array($files)) {
foreach ($files as $filename) {
if (pathinfo($filename, PATHINFO_EXTENSION) === 'php') {
$templates[] = basename($filename, '.php');
}
}
}
return $templates;
}
示例12: findAvailableTemplates
public function findAvailableTemplates(Theme $theme)
{
$files = $this->filesystem->files($theme->getTemplateDirectory());
$templates = [];
if (is_array($files)) {
foreach ($files as $file) {
if (strpos($file, '.php') !== false) {
$file = str_replace($theme->getTemplateDirectory() . '/', '', $file);
$templates[] = str_replace('.php', '', $file);
}
}
}
return $templates;
}
示例13: migrate
/**
* run package database migrations
*
* @return void
*/
public function migrate()
{
$fileSystem = new Filesystem();
$classFinder = new ClassFinder();
foreach ($fileSystem->files(__DIR__ . "/migrations") as $file) {
$fileSystem->requireOnce($file);
$migrationClass = $classFinder->findClass($file);
(new $migrationClass())->up();
}
foreach ($fileSystem->files(__DIR__ . "/seeds") as $file) {
$fileSystem->requireOnce($file);
$migrationClass = $classFinder->findClass($file);
(new $migrationClass())->run();
}
}
示例14: create
/**
* @param string $config
* @return ImageManager->response
*/
public function create($config = 'default')
{
$this->backgrounds = $this->files->files(base_path() . "/resources/assets/Captcha/backgrounds");
$this->fonts = $this->files->files(base_path() . "/resources/assets/Captcha/fonts");
$this->configure($config);
$this->text = $this->generate();
$this->canvas = $this->imageManager->canvas($this->width, $this->height, $this->bgColor);
if ($this->bgImage) {
$this->image = $this->imageManager->make($this->background())->resize($this->width, $this->height);
$this->canvas->insert($this->image);
} else {
$this->image = $this->canvas;
}
if ($this->contrast != 0) {
$this->image->contrast($this->contrast);
}
$this->text();
$this->lines();
if ($this->sharpen) {
$this->image->sharpen($this->sharpen);
}
if ($this->invert) {
$this->image->invert($this->invert);
}
if ($this->blur) {
$this->image->blur($this->blur);
}
return $this->image->response('png', $this->quality);
}
示例15: parseDir
private function parseDir($dir)
{
$items = array();
$files = $this->files->files($dir);
foreach ($files as $file) {
$name = basename($file);
$name = str_replace('.php', '', $name);
$items[$name] = (require $file);
}
$dirs = $this->files->directories($dir);
foreach ($dirs as $dir) {
$name = basename($dir);
$items[$name] = $this->parseDir($dir);
}
return $items;
}