當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。