本文整理匯總了PHP中Illuminate\Filesystem\Filesystem::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filesystem::get方法的具體用法?PHP Filesystem::get怎麽用?PHP Filesystem::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTemplate
/**
* @param $view
* @return string
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function getTemplate($view)
{
if (array_key_exists($view, $this->config['templates']['view']) && ($template = $this->config['templates']['view'][$view])) {
return $this->fs->get($template);
}
return '';
}
示例2: it_generated_correct_file_with_content
/** @test */
public function it_generated_correct_file_with_content()
{
$this->artisan('module:make-middleware', ['name' => 'SomeMiddleware', 'module' => 'Blog']);
$file = $this->finder->get($this->modulePath . '/Http/Middleware/SomeMiddleware.php');
$this->assertTrue(str_contains($file, 'class SomeMiddleware'));
$this->assertTrue(str_contains($file, 'public function handle(Request $request, Closure $next)'));
}
示例3: 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;
}
示例4: createMissingController
/**
* @param Request $request
* @return mixed
* @throws \Exception
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function createMissingController(Request $request)
{
$namespace = $request->namespace;
$controller = $request->controller;
$module = $request->module;
//Get controllers folder
$controllersDir = $this->getMainControllerPath();
//Get controller path for new controller
$newControllerDir = $this->getControllerPath($namespace, $module);
//Get controller namespace
$controllerNamespace = $this->getMainControllerNamespace();
//Get namespace for the new controller
$newControllerNamespace = $this->getControllerNamespace($namespace, $module);
//Get the file
$file = $this->getFileLocation($namespace, $module, $controller);
$controllerClass = studly_case($controller . 'Controller');
//Check if file exists
$fileExists = $this->fileExists($file);
//Check if is dir
if (!$this->fs->isDirectory($newControllerDir)) {
$this->fs->makeDirectory($newControllerDir, 0755, true, true);
}
//If file doesnt exist, create the file
if (!$fileExists) {
$template = $this->builder->setNamespace($newControllerNamespace)->setTemplate($this->fs->get($this->config['templates']['controller']))->setClassName(studly_case($controllerClass))->setUses(Request::class)->buildController();
//Store the file
$this->fs->put($file, $template);
//Call the created controller
return app($newControllerNamespace . '\\' . $controllerClass)->index();
}
throw new \Exception('File exists! I don\'t want to override it!');
}
示例5: getStub
/**
* Get a stub file by name.
*
* @param string $name
* @param string $type
* @return string
*/
protected function getStub($name, $type)
{
if (stripos($name, '.php') === false) {
$name = $name . '.php';
}
return $this->filesystem->get($this->getStubsPath($type) . '/' . $name);
}
示例6: 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);
}
示例7: getPayload
/**
* Retrieve an item and expiry time from the cache by key.
*
* @param string $key
* @return array
*/
protected function getPayload($key)
{
$path = $this->path($key);
// If the file doesn't exists, we obviously can't return the cache so we will
// just return null. Otherwise, we'll get the contents of the file and get
// the expiration UNIX timestamps from the start of the file's contents.
try {
$expire = substr($contents = $this->files->get($path), 0, 10);
} catch (Exception $e) {
return ['data' => null, 'time' => null];
}
// If the current time is greater than expiration timestamps we will delete
// the file and return null. This helps clean up the old files and keeps
// this directory much cleaner for us as old files aren't hanging out.
if (time() >= $expire) {
$this->forget($key);
return ['data' => null, 'time' => null];
}
$data = unserialize(substr($contents, 10));
// Next, we'll extract the number of minutes that are remaining for a cache
// so that we can properly retain the time for things like the increment
// operation that may be performed on the cache. We'll round this out.
$time = ceil(($expire - time()) / 60);
return compact('data', 'time');
}
示例8: __construct
/**
* Constructor to set member vars, and read in the
* given config file as json, then convert it to an
* associative array
*
* @param string $tpl
* @param Filesystem $fs
* @param BuildCommand $cmd
*/
public function __construct($tpl, Filesystem $fs, BuildCommand $cmd)
{
$this->command = $cmd;
$this->filesystem = $fs;
$this->command->comment("Foreman", "Reading template from {$tpl}");
$this->config = json_decode($this->filesystem->get($tpl), true);
}
示例9: createFile
public function createFile(array $data)
{
$project = $this->repository->skipPresenter()->find($data['project_id']);
//dd($project);
$projectFile = $project->files()->create($data);
$this->storage->put($projectFile->id . "." . $data['extension'], $this->filesystem->get($data['file']));
}
示例10: fire
/**
* Execute the console command.
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function fire()
{
$fullPath = $this->createBaseMigration();
$this->files->put($fullPath, $this->files->get(__DIR__ . '/stubs/database.stub'));
$this->info('Migration created successfully!');
$this->call('dump-autoload');
}
示例11: fire
/**
* Execute the console command.
*/
public function fire()
{
$fullPath = $this->createBaseMigration();
$this->files->put($fullPath, $this->files->get(__DIR__ . '/stubs/database.stub'));
$this->info('Migration created successfully! Don\'t forget to run "artisan migrate".');
$this->composer->dumpAutoloads();
}
示例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: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (file_exists($compiled = base_path() . '/bootstrap/compiled.php')) {
$this->error('Error generating IDE Helper: first delete bootstrap/compiled.php (php artisan clear-compiled)');
} else {
$filename = $this->argument('filename');
$format = $this->option('format');
// Strip the php extension
if (substr($filename, -4, 4) == '.php') {
$filename = substr($filename, 0, -4);
}
$filename .= '.' . $format;
if ($this->option('memory')) {
$this->useMemoryDriver();
}
$helpers = '';
if ($this->option('helpers') || $this->config->get('laravel-ide-helper::include_helpers')) {
foreach ($this->config->get('laravel-ide-helper::helper_files', array()) as $helper) {
if (file_exists($helper)) {
$helpers .= str_replace(array('<?php', '?>'), '', $this->files->get($helper));
}
}
} else {
$helpers = '';
}
$generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers);
$content = $generator->generate($format);
$written = $this->files->put($filename, $content);
if ($written !== false) {
$this->info("A new helper file was written to {$filename}");
} else {
$this->error("The helper file could not be created at {$filename}");
}
}
}
示例14: getStub
/**
* Get the given stub by name.
*
* @param string $table
*
* @return void
*/
protected function getStub($name)
{
if (stripos($name, '.php.stub') === false) {
$name = $name . '.php.stub';
}
return $this->files->get($this->getStubPath() . '/' . $name);
}
示例15: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (!$this->files->put(app_path() . '/Http/Controllers/Controller.php', $this->files->get(__DIR__ . '/stubs/Controller.stub'))) {
$this->error('Could not update the Controller abstract class');
} else {
$this->info('Abstract Controller class been successfully updated');
}
if ($this->makeMotorsDirectory()) {
Artisan::call('make:httplayer:basemotor', array());
$this->info(Artisan::output());
$this->info('app\\Http\\Motors :');
$this->info('Motors Directory has been successfully created! ');
} else {
$this->error('WHhhooppss! There was a problem! please verify your permissions');
return false;
}
if ($this->makeTraitsDirectory()) {
if (!$this->files->put(app_path() . '/Http/Traits/CRUDTrait.php', $this->files->get(__DIR__ . '/stubs/CRUDtrait.stub'))) {
$this->error('Could not update the Controller abstract class');
} else {
$this->info('Abstract Controller class been successfully updated');
}
$this->info('app\\Http\\Traits :');
$this->info('Motors Directory has been successfully created! ');
} else {
$this->error('WHhhooppss! There was a problem! please verify your permissions');
return false;
}
return true;
}