本文整理匯總了PHP中Illuminate\Support\Facades\File::allFiles方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::allFiles方法的具體用法?PHP File::allFiles怎麽用?PHP File::allFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\File
的用法示例。
在下文中一共展示了File::allFiles方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: dumpFiles
/**
* Returns an array containing the full path to each dump file.
*
* @return array
*/
private function dumpFiles()
{
$files = [];
foreach (File::allFiles(Config::dumpPath()) as $dumpFile) {
$files[] = $dumpFile->getRealpath();
}
sort($files);
return $files;
}
示例2: map
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
* @param Router $router
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function ($router) {
$directory = File::allFiles(app_path() . '/Http/Routes');
foreach ($directory as $file) {
require_once $file->getPathName();
}
require_once app_path() . '/Http/Helpers.php';
});
}
示例3: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// Start the progress bar
$bar = $this->helper->barSetup($this->output->createProgressBar(7));
$bar->start();
// Common variables
$vendor = strtolower($this->argument('vendor'));
$name = strtolower($this->argument('name'));
$path = getcwd() . '/packages/';
$fullPath = $path . $vendor . '/' . $name;
$cVendor = studly_case($vendor);
$cName = studly_case($name);
$requirement = '"psr-4": {
"' . $cVendor . '\\\\' . $cName . '\\\\": "packages/' . $vendor . '/' . $name . '/src",';
$appConfigLine = 'App\\Providers\\RouteServiceProvider::class,
' . $cVendor . '\\' . $cName . '\\' . 'ServiceProvider::class,';
// Start creating the package
$this->info('Creating package ' . $vendor . '\\' . $name . '...');
if (!$this->option('force')) {
$this->helper->checkExistingPackage($path, $vendor, $name);
}
$bar->advance();
// Create the package directory
$this->info('Creating packages directory...');
$this->helper->makeDir($path);
$bar->advance();
// Create the vendor directory
$this->info('Creating vendor...');
$this->helper->makeDir($path . $vendor);
$bar->advance();
// Copying package skeleton
$this->info('Copying package skeleton...');
File::copyDirectory(__DIR__ . '/../skeleton', $fullPath);
foreach (File::allFiles($fullPath) as $file) {
$search = [':vendor_name', ':VendorName', ':package_name', ':PackageName'];
$replace = [$vendor, $cVendor, $name, $cName];
$newfile = substr($file, 0, -5);
$this->helper->replaceAndSave($file, $search, $replace, $newfile, $deleteOldFile = true);
}
$bar->advance();
// Add it to composer.json
$this->info('Adding package to composer and app...');
$this->helper->replaceAndSave(getcwd() . '/composer.json', '"psr-4": {', $requirement);
//And add it to the providers array in config/app.php
$this->helper->replaceAndSave(getcwd() . '/config/app.php', 'App\\Providers\\RouteServiceProvider::class,', $appConfigLine);
$bar->advance();
// Finished creating the package, end of the progress bar
$bar->finish();
$this->info('Package created successfully!');
$this->output->newLine(2);
$bar = null;
}
示例4: handle
public function handle()
{
if (($table = $this->option('table')) === null) {
$tables = $this->DBHelper->listTables();
$table = $this->choice('Choose table:', $tables, null);
}
$columns = collect($this->DBHelper->listColumns($table));
$this->transformer->setColumns($columns);
$namespace = config('thunderclap.namespace');
$moduleName = str_replace('_', '', title_case($table));
$containerPath = config('thunderclap.target_dir', base_path('modules'));
$modulePath = $containerPath . DIRECTORY_SEPARATOR . $moduleName;
// 1. check existing module
if (is_dir($modulePath)) {
$overwrite = $this->confirm("Folder {$modulePath} already exist, do you want to overwrite it?");
if ($overwrite) {
File::deleteDirectory($modulePath);
} else {
return false;
}
}
// 2. create modules directory
$this->info('Creating modules directory...');
$this->packerHelper->makeDir($containerPath);
$this->packerHelper->makeDir($modulePath);
// 3. copy module skeleton
$stubs = __DIR__ . '/../../stubs';
$this->info('Copying module skeleton into ' . $modulePath);
File::copyDirectory($stubs, $modulePath);
$templates = ['module-name' => str_replace('_', '-', $table), 'route-prefix' => config('thunderclap.routes.prefix')];
// 4. rename file and replace common string
$search = [':Namespace:', ':module_name:', ':module-name:', ':module name:', ':Module Name:', ':moduleName:', ':ModuleName:', ':FILLABLE:', ':TRANSFORMER_FIELDS:', ':VALIDATION_RULES:', ':LANG_FIELDS:', ':TABLE_HEADERS:', ':TABLE_FIELDS:', ':DETAIL_FIELDS:', ':FORM_CREATE_FIELDS:', ':FORM_EDIT_FIELDS:', ':VIEW_EXTENDS:', ':route-prefix:', ':route-middleware:', ':route-url-prefix:'];
$replace = [$namespace, snake_case($table), $templates['module-name'], str_replace('_', ' ', strtolower($table)), ucwords(str_replace('_', ' ', $table)), str_replace('_', '', camel_case($table)), str_replace('_', '', title_case($table)), $this->transformer->toFillableFields(), $this->transformer->toTransformerFields(), $this->transformer->toValidationRules(), $this->transformer->toLangFields(), $this->transformer->toTableHeaders(), $this->transformer->toTableFields(), $this->transformer->toDetailFields(), $this->transformer->toFormCreateFields(), $this->transformer->toFormUpdateFields(), config('thunderclap.view.extends'), $templates['route-prefix'], $this->toArrayElement(config('thunderclap.routes.middleware')), $this->getRouteUrlPrefix($templates['route-prefix'], $templates['module-name'])];
foreach (File::allFiles($modulePath) as $file) {
if (is_file($file)) {
$newFile = $deleteOriginal = false;
if (Str::endsWith($file, '.stub')) {
$newFile = Str::substr($file, 0, -5);
$deleteOriginal = true;
}
$this->packerHelper->replaceAndSave($file, $search, $replace, $newFile, $deleteOriginal);
}
}
$this->warn('Add following service provider to config/app.php ====> ' . $namespace . '\\' . ucwords(str_replace('_', ' ', $table)) . '\\ServiceProvider::class,');
}
示例5: bootRoutes
protected function bootRoutes()
{
$config = $this->app['config'];
if ($config->has('routie.path')) {
$root = $config->get('routie.path');
if (File::isDirectory($root)) {
$path = str_replace('\\', '/', $root);
$path = '/' . $path;
$files = File::allFiles($path);
foreach ($files as $file) {
$filename = str_replace('/' . base_path() . '/', null, $file->getPathname());
$filename = ucfirst($filename);
$filename = explode('.', $filename)[0];
$filename = str_replace('/', '\\', $filename);
$this->app->make($filename);
}
}
}
}
示例6: _minify
/**
* Minify files
*
*/
private function _minify()
{
$this->info("Minifying...");
//If we don't have directories to scan
if (empty($this->_directories)) {
$this->error('No javascript directories to scan');
return false;
}
foreach ($this->_directories as $folder) {
foreach (File::allFiles($this->_assetsDirectory . '/' . $folder) as $file) {
$in = $file->getPathname();
if ($file->getExtension() == 'js' && substr($in, -7) != '.min.js' && substr($in, -8) != '.pack.js') {
$out = str_replace('.js', '.min.js', $file->getPathname());
shell_exec("uglifyjs " . $in . " -c -o " . $out);
$this->line("\t" . $in . " → " . $out);
}
}
}
return true;
}
示例7: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$from = $this->argument('from_locale');
$to = $this->argument('to_locale');
$Lari18n = Lari18n::getInstance();
$data = $Lari18n->retrieveI18nData();
$languages = $data['languages'];
$languagesPath = $data['paths']['lang'];
// check
if (!in_array($from, $languages)) {
$this->error('There is no locale [' . $from . ']');
}
if (in_array($to, $languages)) {
$this->error('The [' . $to . '] locale already exist');
}
// Create the new language directory
File::copyDirectory($languagesPath . '/' . $from, $languagesPath . '/' . $to);
$files = File::allFiles($languagesPath . '/' . $to);
$Lari18n->reinitialiseFiles($files, $to);
$this->info('The [' . $to . '] translation directory as been created from [' . $from . '] translations files');
}
示例8: _minify
/**
* Minify files
*
*/
private function _minify()
{
$this->info("Minifying...");
//If we don't have directories to scan
if (empty($this->_directories)) {
$this->error('No css directories to scan');
return false;
}
foreach ($this->_directories as $folder) {
foreach (File::allFiles($this->_assetsDirectory . '/' . $folder) as $file) {
$in = $file->getPathname();
if ($file->getExtension() == 'css' && substr($in, -8) != '.min.css' && substr($in, -9) != '.pack.css') {
$out = str_replace('.css', '.min.css', $file->getPathname());
$command = 'cat ' . $in . ' | sed -e \'s/^[ \\t]*//g; s/[ \\t]*$//g; s/\\([:{;,]\\) /\\1/g; s/ {/{/g; s/\\/\\*.*\\*\\///g; /^$/d\' | sed -e :a -e \'$!N; s/\\n\\(.\\)/\\1/; ta\' > ' . $out;
shell_exec($command);
$this->line("\t" . $in . " → " . $out);
}
}
}
return true;
}
示例9: findAssets
/**
* Search for the assets in the passed path
* taking into account configured base paths (workbench, vendor, etc)
*
* @param string $path The path to search
* @param string $package The package the assets belong to
* @return array|null The array of SplFileInfo objects or null
*/
protected function findAssets($path, $package)
{
$paths = array_merge($this->paths, $this->config->get('asset::search_paths'));
foreach ($paths as $searchPath) {
$fullPath = base_path() . $searchPath . '/' . $package . '/' . $path;
if (File::isDirectory($fullPath)) {
return File::allFiles($fullPath);
} elseif (File::isFile($fullPath)) {
return Finder::create()->depth(0)->name(basename($fullPath))->in(dirname($fullPath));
}
}
}
示例10:
<?php
use Illuminate\Support\Facades\File;
foreach (File::allFiles(app_path('Http/Routes')) as $route) {
$path = $route->getPathname();
if ($route->getExtension() === 'php') {
require_once $path;
}
}
示例11:
<?php
use Illuminate\Support\Facades\File;
foreach (File::allFiles(app_path() . '/Http/Routes') as $partial) {
require_once $partial->getPathName();
}
示例12: handle
/**
* Execute the Command.
*/
public function handle()
{
// Get all the models
$modelFiles = File::allFiles(base_path('scaffolder-config/models/'));
// Start progress bar
$this->output->progressStart(count($modelFiles));
// Get app config
$scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json'));
// Compilers
$modelCompiler = new ModelCompiler();
$migrationCompiler = new MigrationCompiler();
$controllerCompiler = new ControllerCompiler();
$indexViewCompiler = new IndexViewCompiler();
$createViewCompiler = new CreateViewCompiler();
$editViewCompiler = new EditViewCompiler();
$pageLayoutViewCompiler = new PageLayoutCompiler();
$routeCompiler = new RouteCompiler();
// Compiler output
$modelCompilerOutput = [];
$controllerCompilerOutput = [];
$viewCompilerOutput = [];
$migrationCompilerOutput = [];
// Sidenav links
$sidenavLinks = [];
// Compiled routes
$compiledRoutes = '';
// Get stubs
$modelStub = File::get($this->stubsDirectory . 'Model.php');
$migrationStub = File::get($this->stubsDirectory . 'Migration.php');
$controllerStub = File::get($this->stubsDirectory . 'Controller.php');
$indexViewStub = File::get($this->themeViews->getIndexPath());
$createViewStub = File::get($this->themeViews->getCreatePath());
$editViewStub = File::get($this->themeViews->getEditPath());
$routeStub = File::get($this->stubsDirectory . 'ResourceRoute.php');
// Create models directory
Directory::createIfNotExists(app_path('Models'));
// Iterate over model files
foreach ($modelFiles as $modelFile) {
// Get model name
$modelName = ucwords($modelFile->getBasename('.' . $modelFile->getExtension()));
// Get model data
$modelData = Json::decodeFile($modelFile->getRealPath());
// Create views directory
Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName)));
$modelHash = md5_file($modelFile->getRealPath());
// Compile stubs
array_push($modelCompilerOutput, $modelCompiler->compile($modelStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
array_push($controllerCompilerOutput, $controllerCompiler->compile($controllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
array_push($migrationCompilerOutput, $migrationCompiler->compile($migrationStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash));
$compiledRoutes .= $routeCompiler->compile($routeStub, $modelName, $modelData, $scaffolderConfig, null);
// Add entity link
array_push($sidenavLinks, $modelName);
// Advance progress
$this->output->progressAdvance();
}
// Store compiled routes
$routeCompiler->compileGroup(File::get($this->stubsDirectory . 'Routes.php'), $compiledRoutes, $scaffolderConfig);
// Create layouts directory
Directory::createIfNotExists(base_path('resources/views/layouts'));
// Store compiled page layout
array_push($viewCompilerOutput, $pageLayoutViewCompiler->compile(File::get($this->themeLayouts->getPagePath()), null, null, $scaffolderConfig, null, ['links' => $sidenavLinks]));
// Store create layout
File::copy($this->themeLayouts->getCreatePath(), base_path('resources/views/layouts/create.blade.php'));
array_push($viewCompilerOutput, base_path('resources/views/layouts/create.blade.php'));
// Store edit layout
File::copy($this->themeLayouts->getEditPath(), base_path('resources/views/layouts/edit.blade.php'));
array_push($viewCompilerOutput, base_path('resources/views/layouts/edit.blade.php'));
// Store dashboard
File::copy($this->themeViews->getDashboardPath(), base_path('resources/views/dashboard.blade.php'));
array_push($viewCompilerOutput, base_path('resources/views/dashboard.blade.php'));
// Finish progress
$this->output->progressFinish();
// Summary
$this->comment('- Files created');
$this->comment('- - Views');
foreach ($viewCompilerOutput as $viewFile) {
$this->info('- - - ' . $viewFile);
}
$this->comment('- - Controllers');
foreach ($controllerCompilerOutput as $controllerFile) {
$this->info('- - - ' . $controllerFile);
}
$this->comment('- - Migrations');
foreach ($migrationCompilerOutput as $migrationFile) {
$this->info('- - - ' . $migrationFile);
}
$this->comment('- - Models');
foreach ($modelCompilerOutput as $modelFile) {
$this->info('- - - ' . $modelFile);
}
}
示例13: handle
/**
* Execute the Command.
*/
public function handle()
{
$scaffoldApi = $this->option('api');
$webExecution = $this->option('webExecution');
try {
// Get all the models
$modelFiles = File::allFiles(base_path('scaffolder-config/models/'));
// Get app config
$scaffolderConfig = Json::decodeFile(base_path('scaffolder-config/app.json'));
$apiDirectory = strtolower(str_replace(' ', '-', $scaffolderConfig->name . '-api'));
// Compilers
$modelCompiler = new ModelCompiler();
$apiModelCompiler = new ApiModelCompiler();
$migrationCompiler = new MigrationCompiler();
$controllerCompiler = new ControllerCompiler();
$apiControllerCompiler = new ApiControllerCompiler();
$indexViewCompiler = new IndexViewCompiler();
$createViewCompiler = new CreateViewCompiler();
$editViewCompiler = new EditViewCompiler();
$dashboardViewCompiler = new DashboardViewCompiler();
$welcomeViewCompiler = new WelcomeViewCompiler();
$loginViewCompiler = new LoginViewCompiler();
$pageLayoutViewCompiler = new PageLayoutCompiler();
$createLayoutCompiler = new CreateLayoutCompiler();
$editLayoutCompiler = new EditLayoutCompiler();
$routeCompiler = new RouteCompiler();
$apiRouteCompiler = new ApiRouteCompiler();
// Compiler output
$modelCompilerOutput = [];
$apiModelCompilerOutput = [];
$controllerCompilerOutput = [];
$apiControllerCompilerOutput = [];
$viewCompilerOutput = [];
$migrationCompilerOutput = [];
// Sidenav links
$sidenavLinks = [];
// Compiled routes
$compiledRoutes = '';
$compiledApiRoutes = '';
// Get stubs
$modelStub = File::get($this->stubsDirectory . 'Model.php');
$apiModelStub = File::get($this->stubsDirectory . 'api/Model.php');
$migrationStub = File::get($this->stubsDirectory . 'Migration.php');
$controllerStub = File::get($this->stubsDirectory . 'Controller.php');
$apiControllerStub = File::get($this->stubsDirectory . 'api/Controller.php');
$indexViewStub = File::get($this->themeViews->getIndexPath());
$createViewStub = File::get($this->themeViews->getCreatePath());
$editViewStub = File::get($this->themeViews->getEditPath());
$routeStub = File::get($this->stubsDirectory . 'ResourceRoute.php');
$apiRouteStub = File::get($this->stubsDirectory . 'api/ResourceRoute.php');
// Create models directory
Directory::createIfNotExists(app_path('Models'));
// Initialize API
if ($scaffoldApi) {
if (!(new \FilesystemIterator(base_path('../' . $apiDirectory)))->valid()) {
$this->writeStatus('Initializing API ...', $webExecution);
$this->call('scaffolder:api-initialize', ['name' => $scaffolderConfig->name, 'domain' => $scaffolderConfig->api->domain, '--webExecution' => $webExecution]);
$this->output->newLine();
} else {
$this->writeStatus('API already initialized', $webExecution);
}
// Create models directory
Directory::createIfNotExists(base_path('../' . $apiDirectory . '/app/Models'));
}
$this->writeStatus('Compiling ...', $webExecution);
$this->output->newLine();
// Start progress bar
$this->output->progressStart(count($modelFiles));
// Iterate over model files
foreach ($modelFiles as $modelFile) {
// Get model name
$modelName = ucwords($modelFile->getBasename('.' . $modelFile->getExtension()));
// Get model data
$modelData = Json::decodeFile($modelFile->getRealPath());
// Create views directory
Directory::createIfNotExists(base_path('resources/views/' . strtolower($modelName)));
$modelHash = md5_file($modelFile->getRealPath());
// Compile stubs
array_push($modelCompilerOutput, $modelCompiler->compile($modelStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
if ($scaffoldApi) {
array_push($apiModelCompilerOutput, $apiModelCompiler->compile($apiModelStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
}
array_push($controllerCompilerOutput, $controllerCompiler->compile($controllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
if ($scaffoldApi) {
array_push($apiControllerCompilerOutput, $apiControllerCompiler->compile($apiControllerStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
}
array_push($migrationCompilerOutput, $migrationCompiler->compile($migrationStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->extensions));
array_push($viewCompilerOutput, $indexViewCompiler->compile($indexViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
array_push($viewCompilerOutput, $createViewCompiler->compile($createViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
array_push($viewCompilerOutput, $editViewCompiler->compile($editViewStub, $modelName, $modelData, $scaffolderConfig, $modelHash, $this->themeExtension, $this->extensions));
$compiledRoutes .= $routeCompiler->compile($routeStub, $modelName, $modelData, $scaffolderConfig, null, $this->extensions);
if ($scaffoldApi) {
$compiledApiRoutes .= $apiRouteCompiler->compile($apiRouteStub, $modelName, $modelData, $scaffolderConfig, null, $this->extensions);
}
// Add entity link
array_push($sidenavLinks, ['modelName' => $modelName, 'modelLabel' => $modelData->modelLabel]);
// Advance progress
//.........這裏部分代碼省略.........
示例14: allFilesList
/**
* Get list of all files in the views folder
* @return mixed
*/
public function allFilesList($dir_path)
{
$files = [];
if (File::exists($dir_path)) {
$dir_files = File::allFiles($dir_path);
foreach ($dir_files as $file) {
$path = basename($file);
$name = strstr(basename($file), '.', true);
$files[$name] = $path;
}
}
return $files;
}
示例15: refresh
public function refresh()
{
DB::beginTransaction();
try {
$image_files = DB::table($this->_table)->select('id', 'dir', 'filename')->get();
$exists_image_paths = [];
foreach ($image_files as $key => $image_file) {
$path = $this->filePath($image_file->dir, $image_file->filename);
if (!file_exists($path)) {
DB::table($this->_table)->where('id', $image_file->id)->delete();
} else {
$exists_image_paths[] = public_path($this->_path . '/' . $image_file->dir . '/' . $image_file->filename);
}
}
$files = File::allFiles($this->_path);
foreach ($files as $file) {
$remove_path = $file->getRealPath();
if (!in_array($remove_path, $exists_image_paths)) {
File::delete($remove_path);
}
}
DB::commit();
return true;
} catch (Exception $e) {
DB::rollback();
return false;
}
}