当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::isFile方法代码示例

本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::isFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::isFile方法的具体用法?PHP Filesystem::isFile怎么用?PHP Filesystem::isFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Filesystem\Filesystem的用法示例。


在下文中一共展示了Filesystem::isFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public function get($path, array $data = array())
 {
     $filename = $this->files->name($path) . '.' . $this->files->extension($path);
     $compile_path = \Config::get('view.compiled') . DIRECTORY_SEPARATOR . $filename;
     $template_last_modified = $this->files->lastModified($path);
     $cache_last_modified = $this->files->isFile($compile_path) ? $this->files->lastModified($compile_path) : $template_last_modified;
     $view = $this->files->get($path);
     $app = app();
     // $m = new Mustache_Engine($app['config']->get('handlelars'));
     // Configuration
     $cache_disabled = false;
     $helpers = \Config::get('handlelars.helpers');
     // Precompile templates to view cache when necessary
     $compile = $template_last_modified >= $cache_last_modified || $cache_disabled;
     if ($compile) {
         $tpl = LightnCandy::compile($view, compact('helpers'));
         $this->files->put($compile_path, $tpl);
     }
     if (isset($data['__context']) && is_object($data['__context'])) {
         $data = $data['__context'];
     } else {
         $data = array_map(function ($item) {
             return is_object($item) && method_exists($item, 'toArray') ? $item->toArray() : $item;
         }, $data);
     }
     $renderer = $this->files->getRequire($compile_path);
     return $renderer($data);
 }
开发者ID:truemedia,项目名称:handlelars,代码行数:28,代码来源:MustacheEngine.php

示例2: read

 /**
  * 事前ファイル取得
  *
  * @param string $fileName ファイル名
  * @param string $initialValue ファイルが存在しない場合の初期値
  * @return string ファイルの内容
  */
 public function read($fileName, $initialValue = '')
 {
     if (!$this->file->isFile($fileName)) {
         return $initialValue;
     }
     // 前回の保存データーを取得
     return $this->file->get($fileName);
 }
开发者ID:HiroKws,项目名称:zakkuto-laravel-hub-site,代码行数:15,代码来源:PriorDateReader.php

示例3: getChangelog

 /**
  * @param string $directory
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  *
  * @return array
  */
 private function getChangelog($directory)
 {
     if (!$this->finder->isFile($directory . '/changelog.yml')) {
         return [];
     }
     $yamlFile = $this->finder->get($directory . '/changelog.yml');
     $yamlParser = new Parser();
     $changelog = $yamlParser->parse($yamlFile);
     $changelog['versions'] = $this->limitLastVersionsAmount(array_get($changelog, 'versions', []));
     return $changelog;
 }
开发者ID:SocietyCMS,项目名称:Modules,代码行数:18,代码来源:StylistThemeManager.php

示例4: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // 確認是否有 api key
     if (null === $this->apiPublicKey) {
         $this->error('Invalid VirusTotal api public key.');
         return;
     }
     if (!$this->filesystem->isFile($file = $this->argument('file'))) {
         $this->error('File not exists.');
         return;
     }
     // 取得欲儲存的 Model
     if (null === ($model = $this->option('model'))) {
         $model = $this->ask('The Eloquent ORM Model');
     }
     // 取得欲儲存的欄位
     if (null === ($column = $this->option('column'))) {
         $column = $this->ask('The table\'s column to store the result');
     }
     // 取得欲儲存的欄位
     if (null === ($index = $this->option('index'))) {
         $index = $this->ask('The primary key\'s value to specific row');
     }
     // 檢查 Model 是否存在
     if (!class_exists($model)) {
         $this->error('Model not exists.');
         return;
     }
     $model = (new $model())->find($index);
     // 檢查該比資料是否存在
     if (null === $model) {
         $this->error('Model not exists');
         return;
     }
     // 檢查欄位是否存在
     if (!Schema::hasColumn($model->getTableName(), $column)) {
         $this->error('Column not exists.');
         return;
     }
     // 檢查是否有替代檔名
     if (null !== ($fakeName = $this->option('fakeName')) && strlen($fakeName) > 0) {
         $fakePath = temp_path($fakeName);
         $this->filesystem->copy($file, $fakePath);
         $file = $fakePath;
     }
     $virusTotal = new File($this->apiPublicKey);
     $report = $virusTotal->scan($file);
     $model->{$column} = $report['permalink'];
     $model->save();
     if (isset($fakePath)) {
         $this->filesystem->delete($fakePath);
     }
     $this->info('File scan successfully!');
 }
开发者ID:BePsvPT,项目名称:CCU,代码行数:59,代码来源:ScanFiles.php

示例5: init

 /**
  * 初始化匯入資料.
  *
  * @return void
  */
 protected function init()
 {
     $dir = $this->option('dir') ? realpath($this->option('dir')) : false;
     if (false !== $dir && $this->filesystem->isDirectory($dir)) {
         $this->files = array_merge($this->files, $this->filesystem->glob(file_build_path($dir, '*.html')));
     }
     $file = $this->option('file') ? realpath($this->option('file')) : false;
     if (false !== $file && ends_with($file, '.html') && $this->filesystem->isFile($file)) {
         $this->files[] = $file;
     }
 }
开发者ID:BePsvPT,项目名称:CCU-Plus,代码行数:16,代码来源:ImportCourse.php

示例6: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $paths = ServiceProvider::pathsToPublish($this->option('provider'), $this->option('tag'));
     foreach ($paths as $from => $to) {
         if ($this->files->isFile($from)) {
             $this->publishFile($from, $to);
         } elseif ($this->files->isDirectory($from)) {
             $this->publishDirectory($from, $to);
         }
     }
     $this->info('Publishing Complete!');
 }
开发者ID:fparralejo,项目名称:btrabajo,代码行数:17,代码来源:VendorPublishCommand.php

示例7: scan

 /**
  * Scans a directory
  *
  * @param string $path
  * @return SourceIterator
  */
 public function scan($path)
 {
     if ($this->fs->isDirectory($path)) {
         $iterator = $this->getSourceIterator($path, self::SOURCE_FILE_EXTENSION);
     } elseif ($this->fs->isFile($path)) {
         $filename = $this->getFilePattern($path);
         $path = dirname($path);
         $iterator = $this->getSourceIterator($path, $filename);
     } else {
         throw new RuntimeException(sprintf('Path not found: %s', $path));
     }
     return new SourceIterator($iterator, new Reader($this->fs));
 }
开发者ID:kabirbaidhya,项目名称:Inspector,代码行数:19,代码来源:CodeScanner.php

示例8: fire

 /**
  * Fire the install script.
  *
  * @param Command $command
  *
  * @throws Exception
  *
  * @return mixed
  */
 public function fire(Command $command)
 {
     if (!$this->finder->isFile('.env')) {
         throw new Exception('SocietyCMS is not installed. Please run "php artisan society:install" first.');
     }
     if ($command->option('refresh') && !App::environment('demo')) {
         throw new Exception('Refresh option is only available in demo mode.');
     }
     if (!$command->option('force') && !$command->option('refresh')) {
         if (!$command->confirm('Are you sure you want to start Demo Mode?')) {
             throw new Exception('Demo Mode cancelled');
         }
     }
 }
开发者ID:SocietyCMS,项目名称:Core,代码行数:23,代码来源:ProtectInstallation.php

示例9: getEnvironment

 /**
  * @return string
  *
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function getEnvironment()
 {
     $fileSystem = new Filesystem();
     $environment = '';
     $environmentPath = app()->getBasePath() . '/.env';
     if ($fileSystem->isFile($environmentPath)) {
         $environment = trim($fileSystem->get($environmentPath));
         $envFile = app()->getBasePath() . '/.' . $environment;
         if ($fileSystem->isFile($envFile . '.env')) {
             $dotEnv = new Dotenv(app()->getBasePath() . '/', '.' . $environment . '.env');
             $dotEnv->load();
         }
     }
     return $environment;
 }
开发者ID:pongtan,项目名称:framework,代码行数:20,代码来源:ConfigServiceProvider.php

示例10: loadAutoloaderFile

 /**
  * Load autoloader file.
  *
  * @param  string  $filePath
  *
  * @return void
  */
 protected function loadAutoloaderFile($filePath)
 {
     $filePath = $this->finder->resolveExtensionPath($filePath);
     if ($this->files->isFile($filePath)) {
         $this->files->getRequire($filePath);
     }
 }
开发者ID:jitheshgopan,项目名称:extension,代码行数:14,代码来源:Dispatcher.php

示例11: update

 /**
  * Updates an existing template.
  *
  * @param  string  $dirName
  * @param  string  $fileName
  * @param  array   $content
  * @return int
  */
 public function update($dirName, $fileName, $extension, $content, $oldFileName = null, $oldExtension = null)
 {
     $this->validateDirectoryForSave($dirName, $fileName, $extension);
     $path = $this->makeFilePath($dirName, $fileName, $extension);
     /*
      * The same file is safe to rename when the case is changed
      * eg: FooBar -> foobar
      */
     $iFileChanged = $oldFileName !== null && strcasecmp($oldFileName, $fileName) !== 0 || $oldExtension !== null && strcasecmp($oldExtension, $extension) !== 0;
     if ($iFileChanged && $this->files->isFile($path)) {
         throw (new FileExistsException())->setInvalidPath($path);
     }
     /*
      * File to be renamed, as delete and recreate
      */
     $fileChanged = $oldFileName !== null && strcmp($oldFileName, $fileName) !== 0 || $oldExtension !== null && strcmp($oldExtension, $extension) !== 0;
     if ($fileChanged) {
         $this->delete($dirName, $oldFileName, $oldExtension);
     }
     try {
         return $this->files->put($path, $content);
     } catch (Exception $ex) {
         throw (new CreateFileException())->setInvalidPath($path);
     }
 }
开发者ID:jBOKA,项目名称:library,代码行数:33,代码来源:FileDatasource.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('sql-file');
     $filesystem = new Filesystem();
     if (!$filesystem->isFile($file)) {
         throw new FileNotFoundException("We could not find the file you wanted to send to the remote server");
     }
     $vars = $input->getArguments();
     $keyLocation = $vars['ssh-secret'];
     if (!$filesystem->isFile($keyLocation)) {
         $output->writeln(sprintf('<error>Oh NO! We couldn\'t find the private key located here: %s</error>', $keyLocation));
         $pattern = '/^~\\//i';
         if (preg_match($pattern, $keyLocation) === 1) {
             $output->writeln('<error>Maybe use the key absolute path?</error>');
         }
         $output->writeln('<error>We are going to bail and let you fix this. </error>');
         return;
     }
     $auth = ['key' => $vars['ssh-secret']];
     $output->writeln("Connecting to remote host");
     $remote = new Connection('remote', $vars['ssh-host'], $vars['ssh-user'], $auth);
     if ($remote->getGateway()) {
         $output->writeln("Connection established. Transferring file " . $file);
     }
     $fileName = $filesystem->name($file);
     $remoteFile = $fileName;
     $remote->put($file, $remoteFile);
     $output->writeln("File transfered. Importing into database");
     $mysqlCommandFormat = "mysql -u %s -p'%s' %s < %s";
     $mysqlImportCommand = sprintf($mysqlCommandFormat, $vars['db-user'], $vars['db-password'], $vars['db-name'], $remoteFile);
     $mysqlDropDbCommand = sprintf("mysql -u %s -p'%s' -e 'DROP DATABASE %s;'", $vars['db-user'], $vars['db-password'], $vars['db-name']);
     $mysqlCreateDbCommand = sprintf("mysql -u %s -p'%s' -e 'CREATE DATABASE %s;'", $vars['db-user'], $vars['db-password'], $vars['db-name']);
     $remote->run($mysqlDropDbCommand, function ($line) use($output) {
     });
     $remote->run($mysqlCreateDbCommand, function ($line) use($output) {
     });
     $remote->run($mysqlImportCommand, function ($line) use($output) {
         $output->writeln($line);
     });
     /*
      * Cleanup the remote machine
      */
     $remote->run('rm ' . $remoteFile, function ($line) {
     });
     $output->writeln("Remote Importer is ALL DONE !!!");
 }
开发者ID:jjpmann,项目名称:syncer,代码行数:46,代码来源:RemoteImporterCommand.php

示例13: createMissingView

 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function createMissingView(Request $request)
 {
     $path = config('view.paths.0');
     $chunks = explode('.', $request->view);
     $file = last($chunks);
     $fileWithExtension = $file . $this->config['view_extension'];
     unset($chunks[count($chunks) - 1]);
     $fullPath = $path . '/' . implode('/', $chunks);
     $template = $this->getTemplate($file);
     if (!$this->fs->isDirectory($fullPath)) {
         $this->fs->makeDirectory($fullPath, 0755, true, true);
     }
     if (!$this->fs->isFile($fullPath . '/' . $fileWithExtension)) {
         $this->fs->put($fullPath . '/' . $fileWithExtension, $template);
     }
     return redirect()->back();
 }
开发者ID:donny5300,项目名称:modulair-router,代码行数:21,代码来源:ViewNotFoundExceptionController.php

示例14: handle

 /**
  * Handle the command.
  *
  * @param Filesystem $files
  */
 public function handle(Filesystem $files)
 {
     $path = $this->fieldType->getStoragePath();
     if ($path && $files->isFile($path)) {
         return $files->get($path);
     }
     return null;
 }
开发者ID:ramcda,项目名称:editor-field_type,代码行数:13,代码来源:GetFile.php

示例15: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $paths = ServiceProvider::pathsToPublish($this->option('provider'), $this->option('tag'));
     if (empty($paths)) {
         return $this->comment("Nothing to publish.");
     }
     foreach ($paths as $from => $to) {
         if ($this->files->isFile($from)) {
             $this->publishFile($from, $to);
         } elseif ($this->files->isDirectory($from)) {
             $this->publishDirectory($from, $to);
         } else {
             $this->error("Can't locate path: <{$from}>");
         }
     }
     $this->info('Publishing Complete!');
 }
开发者ID:HarveyCheng,项目名称:myblog,代码行数:22,代码来源:VendorPublishCommand.php


注:本文中的Illuminate\Filesystem\Filesystem::isFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。