本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::copy方法的具体用法?PHP Filesystem::copy怎么用?PHP Filesystem::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publishAddFunctionMigration
/**
* Copy migration files from the migrations directory
*
* @access public
* @param string $targetPath
* @return void
*/
public function publishAddFunctionMigration($targetPath)
{
// The wgs84distance migration
$source = __DIR__ . '/../../../' . self::MIGRATION_FUNCTION_NAME . '.php';
$target = $this->getMigrationFileName(self::MIGRATION_FUNCTION_NAME);
$this->doNotOverwriteFile($targetPath, self::MIGRATION_FUNCTION_NAME);
$this->file->copy($source, "{$targetPath}/{$target}");
}
示例2: publishFile
/**
* Publish the file to the given path.
*
* @param string $from
* @param string $to
* @return void
*/
protected function publishFile($from, $to)
{
if ($this->files->exists($to) && !$this->option('force')) {
return;
}
$this->createParentDirectory(dirname($to));
$this->files->copy($from, $to);
$this->status($from, $to, 'File');
}
示例3: handle
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$files = new Filesystem();
$files->copy(__DIR__ . '/stubs/scaffold/Http/Controllers/HomeController.php', app_path('Http/Controllers/HomeController.php'));
$files->copyDirectory(__DIR__ . '/stubs/scaffold/Http/Controllers/Auth', app_path('Http/Controllers/Auth'));
$files->copy(__DIR__ . '/stubs/scaffold/Http/routes.php', app_path('Http/routes.php'));
$files->copy(__DIR__ . '/stubs/scaffold/Providers/AppServiceProvider.php', app_path('Providers/AppServiceProvider.php'));
$files->copyDirectory(__DIR__ . '/stubs/scaffold/resources/views', base_path('resources/views'));
$this->info('Authentication scaffolding complete!');
}
示例4: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$destination = $this->laravel['path'] . '/controllers/RemindersController.php';
if (!$this->files->exists($destination)) {
$this->files->copy(__DIR__ . '/stubs/controller.stub', $destination);
$this->info('Password reminders controller created successfully!');
$this->comment("Route: Route::controller('password', 'RemindersController');");
} else {
$this->error('Password reminders controller already exists!');
}
}
示例5: setUp
public function setUp()
{
$this->fileSystem = new Filesystem();
$this->cache = new Repository(new FileStore($this->fileSystem, './cache'));
$this->fileSystem->copy('./stubs.sqlite', './stubs-real.sqlite');
$capsule = new Capsule();
$capsule->addConnection(['driver' => 'sqlite', 'database' => './stubs-real.sqlite', 'prefix' => '']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$this->connection = $capsule->getDatabaseManager()->connection('default');
}
示例6: setUp
/**
*
*/
public function setUp()
{
parent::setUp();
$this->config = App::make('Illuminate\\Contracts\\Config\\Repository');
$module = App::make('modules');
$this->finder = App::make('Illuminate\\Filesystem\\Filesystem');
$this->imagy = new Imagy(new InterventionFactory(), new ThumbnailsManager($this->config, $module), $this->config);
$this->testbenchPublicPath = __DIR__ . '/../vendor/orchestra/testbench/fixture/public/';
$this->mediaPath = __DIR__ . '/Fixtures/';
$this->finder->copy("{$this->mediaPath}google-map.png", "{$this->testbenchPublicPath}google-map.png");
}
示例7: CreatePowerMigration
public function CreatePowerMigration()
{
$des1 = $this->laravel->path . "/database/migrations/" . date('Y_m_d_His') . "_power_migration_table.php";
$des2 = $this->laravel->path . "/database/migrations/" . date('Y_m_d_His') . "_power_soft_delete_table.php";
$file1 = __DIR__ . '/../../../migrations/PowerMigrationTable.php';
$file2 = __DIR__ . '/../../../migrations/PowerSoftDeleteTable.php';
$f = new Filesystem();
if ($f->copy($file1, $des1) && $f->copy($file2, $des2)) {
return true;
}
return false;
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$fileSystem = new Filesystem();
$files = $fileSystem->allFiles(base_path('resources/themes/' . strtolower($name) . '/public'));
foreach ($files as $file) {
if ($file->getType() === 'file') {
$this->line(public_path($file->getBasename()));
}
}
$this->info("\n\nThese files will be overwritten\n");
if (!$this->option('forced')) {
$result = $this->confirm('Are you sure you want to overwrite any files of the same name?');
} else {
$result = true;
}
if ($result) {
foreach ($files as $file) {
$newFileName = str_replace(base_path('resources/themes/' . strtolower($name) . '/public/'), '', $file);
$this->line('Copying ' . public_path($newFileName) . '...');
if (is_dir($file)) {
$fileSystem->copyDirectory($file, public_path($newFileName));
} else {
@mkdir(public_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
$fileSystem->copy($file, public_path($newFileName));
}
}
} else {
$this->info("\n\nNo files were published\n");
}
}
示例9: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire(Filesystem $files)
{
$data = [];
$newLocale = $this->input->getOption('locale');
foreach (app('module.loader')->getRegisteredModules() as $module) {
if (!is_dir($module->getLocalePath())) {
continue;
}
foreach ($files->directories($module->getLocalePath()) as $localeDir) {
$locale = basename($localeDir);
if ($locale != $this->copiedLocale) {
continue;
}
foreach ($files->allFiles($localeDir) as $localeFile) {
$data[strtolower($module->getName())][] = $localeFile->getRealPath();
}
}
}
$langDirectory = base_path('/resources/lang/packages');
foreach ($data as $namespace => $locales) {
foreach ($locales as $group => $file) {
$filename = pathinfo($file, PATHINFO_FILENAME);
$fileDir = $langDirectory . DIRECTORY_SEPARATOR . $newLocale . DIRECTORY_SEPARATOR . $namespace;
if (!$files->exists($fileDir)) {
$files->makeDirectory($fileDir, 0755, TRUE);
}
$files->copy($file, $fileDir . DIRECTORY_SEPARATOR . $filename . '.php');
}
}
}
示例10: backup
/**
* Backup config file
*/
protected function backup()
{
$from = $this->configFile;
$pathinfo = pathinfo($from);
$to = $pathinfo['dirname'] . DIRECTORY_SEPARATOR . $pathinfo['filename'] . '.bak.php';
$this->file->copy($from, $to);
}
示例11: fire
public function fire()
{
$environment = $this->config->get('app.env');
$gitSnifferEnv = $this->config->get('git-sniffer.env');
if ($environment !== $gitSnifferEnv) {
return;
}
$hooksDir = base_path('.git/hooks');
if (!$this->files->isDirectory($hooksDir)) {
$this->files->makeDirectory($hooksDir, 0755);
}
$preCommitHook = $hooksDir . '/pre-commit';
$preCommitResource = $this->files->dirname(__DIR__) . '/resources/pre-commit';
if ($this->files->exists($preCommitResource)) {
$this->files->copy($preCommitResource, $preCommitHook);
}
}
示例12: createAnonymizer
/**
* Create Anonymizer class.
*
* @param string $dir
*
* @return void
*/
protected function createAnonymizer($dir, $class)
{
$path = "{$dir}/{$class}.php";
if ($this->files->exists($path)) {
$this->error("File {$path} already exists");
return;
}
$this->files->copy(__DIR__ . '/stubs/' . $class . '.stub', $path);
}
示例13: copy
/**
* Function to copy files given in the template
* configuration from the given source to the
* given destination.
*
* The command will take into account if you are
* copying files or directories and act accordingly
*
* @return void
*/
public function copy()
{
$key = str_replace(TemplateReader::STRUCTURE . '.', '', TemplateReader::STRUCTURE_COPY);
$data = array_get($this->config, $key);
foreach ($data as $cp) {
$from = Path::absolute($cp['from'], $this->appDir);
$to = Path::absolute($cp['to'], $this->appDir);
$this->command->comment("Copy", "from {$from} to {$to}");
if (!$this->filesystem->exists(dirname($to))) {
$this->filesystem->makeDirectory(dirname($to), 0777, true);
}
if ($this->filesystem->isDirectory($from) && $this->filesystem->isDirectory($to)) {
$this->filesystem->copyDirectory($from, $to);
} else {
$this->filesystem->copy($from, $to);
}
}
}
示例14: 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!');
}
示例15: getKeyFileArray
/**
* Get the key file and contents.
*
* @return array
*/
public function getKeyFileArray()
{
$path = $this->getKeyFilePath();
$defaultEnvFile = dirname(__FILE__) . "/../Files/.env.default.php";
if (!$this->files->exists($path)) {
$this->files->copy($defaultEnvFile, $path);
// copy default file
}
$envConfig = $this->files->includeFile($path);
return $envConfig;
}