本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::exists方法的具体用法?PHP Filesystem::exists怎么用?PHP Filesystem::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findComposer
/**
* Get the composer command for the environment.
*
* @return string
*/
protected function findComposer()
{
if ($this->files->exists($this->workingPath . '/composer.phar')) {
return 'php ' . $this->workingPath . '/composer.phar';
}
return 'composer';
}
示例2: save
public function save($item, $value, $environment, $group, $namespace = null)
{
$path = DIR_APPLICATION . '/config/generated_overrides';
if (!$this->files->exists($path)) {
$this->files->makeDirectory($path, 0777);
} elseif (!$this->files->isDirectory($path)) {
$this->files->delete($path);
$this->files->makeDirectory($path, 0777);
}
if ($namespace) {
$path = "{$path}/{$namespace}";
if (!$this->files->exists($path)) {
$this->files->makeDirectory($path, 0777);
} elseif (!$this->files->isDirectory($path)) {
$this->files->delete($path);
$this->files->makeDirectory($path, 0777);
}
}
$file = "{$path}/{$group}.php";
$current = array();
if ($this->files->exists($file)) {
$current = $this->files->getRequire($file);
}
array_set($current, $item, $value);
$renderer = new Renderer($current);
return $this->files->put($file, $renderer->render()) !== false;
}
示例3: execute
/**
* Execute the command.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setIo($input, $output);
/** @var Repository $config */
$config = $this->container['config'];
$sourceRepoPath = $config['source.directory'];
$sourceRepoUrl = $config['source.git.url'];
$sourceRepoBranch = $config['source.git.branch'];
$this->checkSourceRepoSettings($sourceRepoPath, $sourceRepoUrl);
$output->writeln(["<b>steak pull configuration:</b>", " Source repository remote is <path>{$sourceRepoUrl}</path>", " Source repository branch is <path>{$sourceRepoBranch}</path>", " Path to local repository is <path>{$sourceRepoPath}</path>"], OutputInterface::VERBOSITY_VERBOSE);
if ($this->files->exists($sourceRepoPath)) {
$workingCopy = $this->git->workingCopy($sourceRepoPath);
if (!$workingCopy->isCloned()) {
throw new RuntimeException("<path>{$sourceRepoPath}</path> exists but is not a git repository.");
}
if ($workingCopy->getBranches()->head() != $sourceRepoBranch) {
throw new RuntimeException("<path>{$sourceRepoPath}</path> exists but isn't on the <path>{$sourceRepoBranch}</path> branch.");
}
$this->git->streamOutput();
$workingCopy->pull();
} else {
$output->writeln(["The source directory <path>{$sourceRepoPath}</path> does not exist.", " Attempting clone from {$sourceRepoUrl}"]);
$this->git->streamOutput();
$this->git->cloneRepository($sourceRepoUrl, $sourceRepoPath, ['single-branch' => true, 'branch' => $sourceRepoBranch]);
$output->writeln("<info>Clone complete! Edit your sources in <path>{$sourceRepoPath}</path></info>");
}
$output->writeln("Try <comment>steak serve</comment> to fire up the local development server...");
}
示例4: delete
public function delete()
{
if (!$this->filesystem->exists($this->path)) {
return;
}
$this->filesystem->deleteDirectory($this->path);
}
示例5: makeViews
/**
* Generate a fully fleshed out controller, if the user wishes.
*/
public function makeViews()
{
$valid = false;
$indexPath = $this->getPath($this->getClassName(), 'index');
$this->makeDirectory($indexPath);
$createPath = $this->getPath($this->getClassName(), 'create');
$this->makeDirectory($createPath);
$editPath = $this->getPath($this->getClassName(), 'edit');
$this->makeDirectory($editPath);
if (!$this->files->exists($indexPath)) {
if ($this->files->put($indexPath, $this->compileViewStub('index'))) {
$valid = true;
}
}
if (!$this->files->exists($createPath)) {
if ($this->files->put($createPath, $this->compileViewStub('create'))) {
$valid = true;
}
}
if (!$this->files->exists($editPath)) {
if ($this->files->put($editPath, $this->compileViewStub('edit'))) {
$valid = true;
}
}
$masterPath = base_path() . '/resources/views/master.blade.php';
$stub = $this->files->get(__DIR__ . '/../stubs/views/master.stub');
if (!$this->files->exists($masterPath)) {
if ($this->files->put($masterPath, $this->compileViewStub('master'))) {
$valid = true;
}
}
return $valid;
}
示例6: read
/**
* {@inheritdoc}
*/
public function read($sessionId)
{
if ($this->files->exists($path = $this->path . '/' . $sessionId)) {
return $this->files->get($path);
}
return '';
}
示例7: findComposer
/**
* Get the composer command for the environment.
*
* @return string
*/
protected function findComposer()
{
if ($this->files->exists($this->workingPath . '/composer.phar')) {
return '"' . PHP_BINARY . '" composer.phar';
}
return 'composer';
}
示例8: destroy
/**
* @param \Exolnet\Image\Imageable $image
* @return bool
*/
public function destroy(Imageable $image)
{
if ($this->filesystem->exists($image->getImagePath())) {
return $this->filesystem->delete($image->getImagePath());
}
return true;
}
示例9: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
if (!$this->confirmToProceed()) {
return;
}
$this->prepareDatabase();
$env = $this->option('env');
if ($this->files->exists(database_path(config('smart-seeder.seedsDir')))) {
$this->migrator->setEnv($env);
}
//otherwise use the default environment
$this->migrator->setConnection($this->input->getOption('database'));
$pretend = $this->input->getOption('pretend');
while (true) {
$count = $this->migrator->rollback($pretend);
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note) {
$this->output->writeln($note);
}
if ($count == 0) {
break;
}
}
$this->line("Seeds reset for {$env}");
}
示例10: getModules
/**
* Modules of installed or not installed.
*
* @param bool $installed
*
* @return \Illuminate\Support\Collection
*/
public function getModules($installed = false)
{
if ($this->modules->isEmpty()) {
if ($this->files->isDirectory($this->getModulePath()) && !empty($directories = $this->files->directories($this->getModulePath()))) {
(new Collection($directories))->each(function ($directory) use($installed) {
if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
$package = new Collection(json_decode($this->files->get($file), true));
if (Arr::get($package, 'type') == 'notadd-module' && ($name = Arr::get($package, 'name'))) {
$module = new Module($name);
$module->setAuthor(Arr::get($package, 'authors'));
$module->setDescription(Arr::get($package, 'description'));
if ($installed) {
$module->setInstalled($installed);
}
if ($entries = data_get($package, 'autoload.psr-4')) {
foreach ($entries as $namespace => $entry) {
$module->setEntry($namespace . 'ModuleServiceProvider');
}
}
$this->modules->put($directory, $module);
}
}
});
}
}
return $this->modules;
}
示例11: lastModified
/**
* Return the last modified timestamp of a view.
*
* @param string $name
* @return integer
* @throws FileNotFoundException
*/
public function lastModified($name)
{
if (!$this->files->exists($name)) {
throw new FileNotFoundException("{$name} does not exist");
}
return $this->files->lastModified($name);
}
示例12: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$model = ucfirst($this->argument('model'));
$path = $this->option('path');
if (empty($path)) {
$path = database_path(config('smart-seeder.seedDir'));
} else {
$path = base_path($path);
}
$env = $this->option('env');
if (!empty($env)) {
$path .= "/{$env}";
}
if (!$this->files->exists($path)) {
// mode 0755 is based on the default mode Laravel use.
$this->files->makeDirectory($path, 755, true);
}
$created = date('Y_m_d_His');
$path .= "/seed_{$created}_{$model}Seeder.php";
$fs = $this->files->get(__DIR__ . '/stubs/DatabaseSeeder.stub');
$namespace = rtrim($this->getAppNamespace(), '\\');
$stub = str_replace('{{seeder}}', "seed_{$created}_" . $model . 'Seeder', $fs);
$stub = str_replace('{{namespace}}', " namespace {$namespace};", $stub);
$stub = str_replace('{{model}}', $model, $stub);
$this->files->put($path, $stub);
$message = "Seed created for {$model}";
if (!empty($env)) {
$message .= " in environment: {$env}";
}
$this->line($message);
}
示例13: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
foreach (User::all() as $user) {
if (!$user->rsaKey) {
throw new \RuntimeException('user ' . $user->email . ' has no RSA key. Create it using key:generate:users');
}
}
if (!$this->filesystem->exists(config('app.backup_key'))) {
$this->warn('Backup key does not exist. We recommend that you create one using key:generate:master');
}
$entries = Entry::all();
foreach ($entries as $entry) {
$list = $this->accessDecider->getUserListForEntry($entry);
if ($list->count() == 0) {
throw new \RuntimeException('Entry #' . $entry->id . ' has no access. Share it.');
}
}
foreach ($entries as $entry) {
if ($entry->password != '') {
continue;
}
echo $entry->id . '... ';
$this->entryCrypt->encrypt($entry->password, $entry);
echo ' encrypted!' . "\n";
}
}
示例14: get
/**
* @param string $locale
* @param string $group
* @return array
*/
public function get($locale, $group)
{
if ($this->fs->exists($path = $this->path . "/{$locale}/{$group}.php")) {
return $this->fs->getRequire($path);
}
return [];
}
示例15: logInfo
/**
* write log
* @param string $logContent [logContent]
* @param string $logDirPath [filepath]
*/
public function logInfo($logContent, $logDirPath)
{
$filesystem = new Filesystem();
if (!$logContent || !$logDirPath) {
return false;
}
if ($this->getMailLog()) {
// log file all path
$logPath = $logDirPath . $this->getLogName();
if ($filesystem->exists($logPath)) {
// everyDay new a file
$content = $filesystem->get($logPath);
if ($logTime = substr($content, 1, 10)) {
if (Carbon::now($this->local)->toDateString() == $logTime) {
$filesystem->append($logPath, $logContent . PHP_EOL);
} else {
$new_log_path = $logDirPath . $logTime . $this->getLogName();
if (!$filesystem->exists($new_log_path)) {
$filesystem->move($logPath, $new_log_path);
}
$filesystem->put($logPath, $logContent);
}
}
} else {
$filesystem->put($logPath, $logContent);
}
}
}