本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::move方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::move方法的具体用法?PHP Filesystem::move怎么用?PHP Filesystem::move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveApk
public function saveApk($file, $label, $name, $icon)
{
$fileSystem = new Filesystem();
$parser = new ApkParser\Parser($file->getRealPath());
$version = $parser->getManifest()->getVersionCode();
$bundle = $parser->getManifest()->getPackageName();
if (!$fileSystem->exists(public_path() . '/builds')) {
$fileSystem->makeDirectory(public_path() . '/builds');
}
if (!$fileSystem->exists(public_path() . '/builds/android')) {
$fileSystem->makeDirectory(public_path() . '/builds/android');
}
if (!$fileSystem->exists(public_path() . '/builds/android/' . $label)) {
$fileSystem->makeDirectory(public_path() . '/builds/android/' . $label);
}
if (!$fileSystem->exists(public_path() . '/builds/android/' . $label . '/' . $version)) {
$fileSystem->makeDirectory(public_path() . '/builds/android/' . $label . '/' . $version);
}
$label_model = Label::where('label_name', '=', $label)->where('build_type_id', '=', self::BUILD_ANDROID_TYPE_ID)->first();
if ($label_model != null) {
$version_model = $label_model->versions()->where('version', '=', $version)->first();
if ($version_model != null) {
$build_version_count = Build::where('version_id', '=', $version_model->id)->count();
$build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => $build_version_count + 1));
} else {
$version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
$build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
}
} else {
$label_model = Label::create(array('label_name' => $label, 'build_type_id' => self::BUILD_ANDROID_TYPE_ID));
$version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
$build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
}
$fn = public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.apk';
if (!$fileSystem->exists(public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build)) {
$fileSystem->makeDirectory(public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build);
}
$fileSystem->move($file->getRealPath(), $fn);
$fileSystem->move($icon->getRealPath(), public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
return Config::get("app.domain") . "/android/builds/{$label}/{$version}/{$build->build}";
}
示例2: save
/**
* @return bool
* @throws Exception
*/
public function save()
{
if ($this->isReadOnly() and !$this->isNew()) {
return false;
}
$status = true;
if ($this->isNew()) {
$newFilename = normalize_path($this->basePath . DIRECTORY_SEPARATOR . $this->changed['name']);
$status = touch($newFilename) !== false;
if ($status) {
chmod($newFilename, 0777);
$this->file = new SplFileObject($newFilename);
}
} elseif ($this->isChanged('name')) {
$newFilename = normalize_path($this->getPath() . '/' . $this->changed['name']);
if ($newFilename != $this->getRealPath()) {
$status = @$this->filesSystem->move($this->getRealPath(), $newFilename);
}
if ($status) {
$this->file = new SplFileObject($newFilename);
}
}
if ($status and $this->isChanged('content')) {
$status = $this->filesSystem->put($this->getRealPath(), $this->changed['content']) !== false;
}
$this->changed = [];
return $status;
}
示例3: 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);
}
}
}
示例4: renameModelsAndRepositories
/**
* Rename models and repositories.
*/
public function renameModelsAndRepositories()
{
$moduleDir = base_path('Modules/' . $this->module);
$paths = [$moduleDir . '/Models/Object.php', $moduleDir . '/Models/ObjectTranslation.php', $moduleDir . '/Repositories/ObjectInterface.php', $moduleDir . '/Repositories/EloquentObject.php'];
foreach ($paths as $path) {
$this->files->move($path, $this->transformFilename($path));
}
}
示例5: moveAssets
protected function moveAssets()
{
// 移動 css 檔
$this->filesystem->move(base_path('resources/views/css/ccu.css.php'), cdn_path('css/ccu.min.css'));
// 移動 js 檔
$this->filesystem->move(temp_path('vendors.min.js'), cdn_path('js/vendors.min.js'));
$this->info('Move assets successfully!');
}
示例6: fire
/**
* Create date folder structure and move migrations into.
*
* @return void
*/
public function fire()
{
$this->basePath = $this->getMigrationPath();
$migrations = $this->migrator->getMigrationFiles($this->basePath);
$count = count($migrations);
if ($count == 0) {
$this->comment('No migrations to move');
return;
}
foreach ($migrations as $migration) {
$datePath = $this->migrator->getDateFolderStructure($migration);
// Move the migration into base migration folder
$this->files->move($this->basePath . '/' . $datePath . $migration . '.php', $this->basePath . '/' . $migration . '.php');
}
$this->info('Migrations disorganised successfully (' . $count . ' migrations moved)');
$this->cleanup();
}
示例7: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$defaultEnvironmentFile = 'bootstrap/environment.local.php';
$environmentFile = 'bootstrap/environment.php';
$this->line('Welcome to TypiCMS');
if (!$this->files->exists($environmentFile) && $this->files->exists($defaultEnvironmentFile)) {
// move default environment file so current environment will be local.
$this->files->move($defaultEnvironmentFile, $environmentFile);
// set environment to local
$this->laravel['env'] = 'local';
$this->line('----------------------');
$this->info('Environment set to local');
$this->line('----------------------');
}
$this->checkThatEnvTemplateExists();
// Ask for database name
$dbName = $this->ask('What is your database name? ');
// Set database credentials in env.local.php and migrate
$this->call('typicms:database', array('database' => $dbName));
$this->line('----------------------');
// Set cache key prefix
$this->call('cache:prefix', array('prefix' => $dbName));
$this->line('----------------------');
// Composer install
if (function_exists('system')) {
$this->info('Running npm install...');
system('npm install');
$this->info('npm packages installed');
$this->line('----------------------');
$this->info('Running bower install...');
system('bower install');
$this->info('Bower packages installed');
$this->line('----------------------');
system('chmod -R 777 app/storage');
$this->info('app/storage is now writable');
system('chmod -R 777 public/uploads');
$this->info('public/uploads is now writable');
} else {
$this->line('You can now make app/storage and public/uploads writable');
$this->line('and run composer install, npm install and bower install.');
}
// Done
$this->line('----------------------');
$this->line('Done. Enjoy TypiCMS!');
}
示例8: backup
protected function backup($file)
{
$backupPath = $this->app->make('path.storage') . '/packages/backup/' . $this->package->getName();
if (!$this->filesystem->isDirectory($backupPath)) {
$this->filesystem->makeDirectory($backupPath, 0755, true);
}
$newFile = $backupPath . '/' . date('Ymdhis') . '_' . basename($file);
$this->filesystem->move($file, $newFile);
}
示例9: handle
/**
* Execute the command.
*
* @return void
*/
public function handle(ValidateFilenameService $validateFilename, Filesystem $filesystem)
{
$files = [];
foreach ($this->files as $file) {
$filename = $validateFilename->execute($this->targetDir, $file);
$filesystem->move($this->originDir . '/' . $file, $this->targetDir . '/' . $filename);
$files[] = $filename;
}
return $files;
}
示例10: fire
/**
* Create date folder structure and move migrations into.
*
* @return void
*/
public function fire()
{
$basePath = $this->getMigrationPath();
$migrations = $this->migrator->getMigrationFiles($basePath, false);
$count = count($migrations);
if ($count == 0) {
$this->comment('No migrations to move');
return;
}
foreach ($migrations as $migration) {
$datePath = $this->migrator->getDateFolderStructure($migration);
// Create folder if it does not already exist
if (!$this->files->exists($basePath . '/' . $datePath)) {
$this->files->makeDirectory($basePath . '/' . $datePath, 0775, true);
}
// Move the migration into its new folder
$this->files->move($basePath . '/' . $migration . '.php', $basePath . '/' . $datePath . $migration . '.php');
}
$this->info('Migrations organised successfully (' . $count . ' migrations moved)');
}
示例11: move
/**
* Function to move files / folders given in the template
* configuration from the given source to the
* given destination.
*
* @return void
*/
public function move()
{
$key = str_replace(TemplateReader::STRUCTURE . '.', '', TemplateReader::STRUCTURE_MOVE);
$data = array_get($this->config, $key);
foreach ($data as $mv) {
if (!empty($mv['from']) && !empty($mv['to'])) {
$from = Path::absolute($mv['from'], $this->appDir);
$to = Path::absolute($mv['to'], $this->appDir);
$this->command->comment("Move", "from {$from} to {$to}");
$this->filesystem->move($from, $to);
}
}
}
示例12: handle
/**
* @param Filesystem $files
* @param AccountManager $manager
* @return mixed
*/
public function handle(Filesystem $files, AccountManager $manager)
{
$temp_dir = storage_path('media') . '/' . $this->owner->getMediaFolder('images');
$name = $this->uniqueName();
$this->image->move($temp_dir, $name);
$temp_file = $temp_dir . $name;
$name_with_extension = $name . $this->extension($temp_file);
$final_path = $temp_file . $name_with_extension;
$files->move($temp_file, $final_path);
$image = $this->dispatch(new StoreNewImage($manager->account(), $this->owner, $final_path));
$files->delete($final_path);
return $image;
}
示例13: store
public function store()
{
$filesystem = new Filesystem();
$advertising = Advertising::where('name', '=', Input::get('name'));
if (!$advertising->count() > 0) {
$advertising = Advertising::create(['name' => Input::get('name'), 'bio' => Input::get('bio')]);
}
if (Input::has('image')) {
$destination = public_path() . "/images/advertising/";
$filename = Input::file('image');
$file = $filesystem->move($destination, $filename);
if ($file) {
$advertising->image = $filename;
}
$advertising->save();
}
if ($advertising) {
return Redirect::to('admin/advertising/' . $advertising->id . '/show', ['advertising' => $advertising, 'add_failed' => 'false']);
}
return View::make('admin.advertising.add', ['add_failed' => 'true']);
/*
if (\Input::get('name')) {
$filesystem = new Filesystem;
$advertising = \Advertising::findOrCreate(\Input::get('name'));
//$advertising_exists = \Advertising::where('name', '=', \Input::get('name'));
if ($exists->id) {
return \View::make('admin.advertising.add', ['add_failed'=> 'true', 'error_msg' => 'An entry for this advertising already exists!']);
}
//$new_advertising = \Advertising::create(\Input::only(['name', 'image', 'bio']));
$advertising->name = \Input::get('name');
$advertising->bio = \Input::get('bio');
if (\Input::has('image')) {
$destination = public_path() . "/images/advertising/";
$filename = \Input::file('image');
$upload_success = $filesystem->move($destination, $filename);
//$upload_success = \Input::file('image')->move($destinationPath, $filename);
if ($upload_success) {
$advertising->image = $filename;
}
}
$advertising->save();
return \View::make('admin.advertising.add', ['add_failed' => 'true']);
}*/
}
示例14: handle
/**
* @param Gravatar $gravatar
* @param Filesystem $files
* @param AccountManager $manager
* @throws \Exception
*/
public function handle(Gravatar $gravatar, Filesystem $files, AccountManager $manager)
{
if ($gravatar->exists($this->user->email)) {
$gravatar->setAvatarSize(512);
$url = $gravatar->get($this->user->email);
$content = file_get_contents($url);
$tmpDir = storage_path('media' . '/' . $this->user->getMediaFolder());
if (!$files->isDirectory($tmpDir)) {
$files->makeDirectory($tmpDir, 0755, true);
}
$path = $tmpDir . sha1(time() . 'user-profile-pic' . $this->user->id);
$files->put($path, $content);
$finalPath = $this->pathWithExtension($path);
$files->move($path, $finalPath);
$this->dispatch(new StoreNewImage($manager->account(), $this->user, $finalPath));
$files->delete($finalPath);
}
}
示例15: backup
/**
* 将非必要文件转移至备份文件夹,以减小 vendor 目录体积
* @return void
*/
public static function backup()
{
$Filesystem = new Filesystem();
$vendorDir = dirname(dirname(dirname(dirname(__DIR__))));
$topDir = dirname($vendorDir);
$backupDir = $topDir . '/VendorCleanerBackup';
// 获取主要规则文件
// 若 vendor 同级目录下存在用户自定义文件,则使用用户自定义文件
if ($Filesystem->exists($topDir . '/VendorCleaner.config.php')) {
$rules = (require $topDir . '/VendorCleaner.config.php');
} else {
$rules = (require 'VendorCleaner/VendorCleaner.config.php');
}
// 分别处理各个资源包
foreach ($rules as $packageDir => $rule) {
if (!file_exists($vendorDir . '/' . $packageDir)) {
continue;
}
// 拆分子规则
$patterns = explode(' ', $rule);
// 执行拆分后的规则
foreach ($patterns as $pattern) {
$Finder = new Finder();
try {
foreach ($Finder->name($pattern)->in($vendorDir . '/' . $packageDir) as $file) {
$backup = str_replace($vendorDir, $backupDir, $file);
if ($file->isDir()) {
// 文件夹处理
$Filesystem->copyDirectory($file, $backup);
$Filesystem->deleteDirectory($file);
} elseif ($file->isFile()) {
// 文件处理
$Filesystem->move($file, $backup);
}
}
} catch (\Exception $e) {
}
}
}
}