當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::put方法代碼示例

本文整理匯總了PHP中Thin\File::put方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::put方法的具體用法?PHP File::put怎麽用?PHP File::put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Thin\File的用法示例。


在下文中一共展示了File::put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct($db)
 {
     $this->orm = $db;
     $this->db = $db->db();
     $this->table = $db->table();
     $dir = Config::get('dir.blizz.store', session_save_path());
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
     $file = $this->dir . DS . 'data.db';
     $new = false;
     if (!is_file($file)) {
         File::create($file);
         $new = true;
         File::put($this->dir . DS . 'age.blizz', '');
     }
     $link = new SQLite3($file);
     Now::set("blizz.link.{$this->db}.{$this->table}", $link);
     if ($new) {
         $this->init();
     }
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:30,代碼來源:blizzstore.php

示例2: model

 public function model($data = [])
 {
     $view = false;
     $db = $this->db;
     $table = $this->table;
     $modelFile = APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db) . DS . ucfirst(Inflector::lower($table)) . '.php';
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql')) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql');
     }
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models')) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models');
     }
     if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db))) {
         File::mkdir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . 'models' . DS . Inflector::lower($db));
     }
     if (!File::exists($modelFile)) {
         File::put($modelFile, str_replace('##class##', ucfirst(Inflector::lower($db)) . ucfirst(Inflector::lower($table)) . 'SQLModel', File::read(__DIR__ . DS . 'dbModel.tpl')));
     }
     $class = '\\Thin\\' . ucfirst(Inflector::lower($db)) . ucfirst(Inflector::lower($table)) . 'SQLModel';
     if (!class_exists($class)) {
         require_once $modelFile;
     }
     $model = $this;
     if (true === $view) {
         $model = self::instance($db, $table);
     }
     return new $class($model, $data);
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:28,代碼來源:Db.php

示例3: write

 public function write($name, $data = [])
 {
     $file = $this->getFile($name);
     File::delete($file);
     $data = is_array($data) ? var_export($data, 1) : var_export([$data], 1);
     File::put($file, "<?php\nreturn " . $data . ';');
     // touch($file, time() - 10);
     return $this;
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:9,代碼來源:Motor.php

示例4: nextId

 private function nextId()
 {
     $id = File::read($this->ids);
     File::delete($this->ids);
     File::put($this->ids, $id + 1);
     return (int) $id;
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:7,代碼來源:flight.php

示例5: makeId

 private function makeId()
 {
     $file = $this->dir . DS . 'lastid.blazz';
     if (is_file($file)) {
         $last = File::read($file);
         $new = $last + 1;
         File::delete($file);
         File::put($file, $new);
         return $new;
     }
     File::put($file, 1);
     return 1;
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:13,代碼來源:blazz.php

示例6: cached

 private function cached($key, $value = null)
 {
     if (false === $this->cache) {
         return null;
     }
     $settings = isAke(self::$configs, $this->entity);
     $event = isAke($settings, 'cache');
     if (!empty($event)) {
         return $this->{$event}($key, $value);
     }
     $file = STORAGE_PATH . DS . 'cache' . DS . $key . '.eav';
     if (empty($value)) {
         if (File::exists($file)) {
             $age = filemtime($file);
             $maxAge = time() - $this->ttl;
             if ($maxAge < $age) {
                 return json_decode(File::get($file), true);
             } else {
                 File::delete($file);
                 return null;
             }
         }
     } else {
         if (File::exists($file)) {
             File::delete($file);
         }
         File::put($file, json_encode($value));
         return true;
     }
 }
開發者ID:noikiy,項目名稱:inovi,代碼行數:30,代碼來源:Dbeav.php

示例7: csv

 private function csv($data)
 {
     $csv = implode("\n", $data);
     $name = date('d_m_Y_H_i_s') . '_' . $this->table . '_export.csv';
     $file = TMP_PUBLIC_PATH . DS . $name;
     File::delete($file);
     File::put($file, $csv);
     Utils::go(str_replace(['jma_dev.php', 'jma_prod.php'], '', URLSITE) . 'tmp/' . $name);
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:9,代碼來源:Dbjson.php

示例8: distantAsset

 public function distantAsset($src)
 {
     $ext = strtolower(Arrays::last(explode('.', $src)));
     $file = Config::get('app.module.assets') . DS . 'cache' . DS . sha1($src) . '.' . $ext;
     $render = '/assets/cache/' . sha1($src) . '.' . $ext;
     if (!file_exists($file)) {
         $ctn = file_get_contents($src);
         File::put($file, $ctn);
     }
     return $render;
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:11,代碼來源:clipp.php

示例9: editpageAction

 public function editpageAction()
 {
     $id = request()->getId();
     if (!is_null($id)) {
         $permission = 'cms';
         $auth = auth()->can($permission);
         if (true === $auth || true === $this->isAdmin) {
             $dirPages = realpath(APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'content' . DS . SITE_NAME . DS . 'pages');
             $dirPartials = realpath(APPLICATION_PATH . DS . '..' . DS . 'public' . DS . 'content' . DS . SITE_NAME . DS . 'partials');
             if (!strlen($dirPages) || !strlen($dirPartials)) {
                 $this->forward('home');
             }
             $pages = File::readdir($dirPages);
             $partials = File::readdir($dirPartials);
             $pages = array_merge($pages, $partials);
             $key = $id - 1;
             $file = isset($pages[$key]) ? $pages[$key] : false;
             if (false !== $file) {
                 if ($this->isPost()) {
                     $html = request()->getHtml();
                     $config = request()->getConfig();
                     $content = "/*\n    {$config}\n*/\n{$html}";
                     File::delete($file);
                     File::put($file, $content);
                     $this->forward('pagelist');
                 } else {
                     $content = fgc($file);
                     $this->view->configPage = repl(array('/*', '*/'), '', $this->getConfigPage($content));
                     $this->view->htmlPage = $this->getHtml($content);
                     $this->view->title = 'Mettre à jour une page';
                 }
             } else {
                 $this->forward('pagelist');
             }
         } else {
             $this->forward('pagelist');
         }
     } else {
         $this->forward('pagelist');
     }
 }
開發者ID:noikiy,項目名稱:inovi,代碼行數:41,代碼來源:staticController.php

示例10: generate

 public static function generate($model, $overwrite = false)
 {
     $file = APPLICATION_PATH . DS . 'models' . DS . 'Crud' . DS . ucfirst(Inflector::camelize($model)) . '.php';
     if (!File::exists($file) || $overwrite) {
         $db = model($model);
         $crud = new Crud($db);
         File::delete($file);
         $tplModel = fgc(__DIR__ . DS . 'Model.tpl');
         $tplField = fgc(__DIR__ . DS . 'Field.tpl');
         $fields = $crud->fields();
         $singular = ucfirst($model);
         $plural = $singular . 's';
         $default_order = $crud->pk();
         $tplModel = str_replace(array('##singular##', '##plural##', '##default_order##'), array($singular, $plural, $default_order), $tplModel);
         $fieldsSection = '';
         foreach ($fields as $field) {
             if ($field != $crud->pk()) {
                 $label = substr($field, -3) == '_id' ? ucfirst(str_replace('_id', '', $field)) : ucfirst(Inflector::camelize($field));
                 $fieldsSection .= str_replace(array('##field##', '##label##'), array($field, $label), $tplField);
             }
         }
         $tplModel = str_replace('##fields##', $fieldsSection, $tplModel);
         File::put($file, $tplModel);
     }
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:25,代碼來源:Tools.php

示例11: prepare

 private function prepare()
 {
     $results = $collection = [];
     $hash = $this->db->getHash();
     $this->cursor = $this->db->motor()->getPath() . DS . 'cursors' . DS . $hash;
     if (is_dir($this->cursor)) {
         $ageCursor = filemtime($this->cursor . DS . '.');
         $ageDb = $this->db->getAge();
         if ($ageDb < $ageCursor) {
             $this->count = count(glob($this->cursor . DS . '*.php', GLOB_NOSORT));
             return;
         } else {
             File::rmdir($this->cursor);
         }
     }
     File::mkdir($this->db->motor()->getPath() . DS . 'cursors');
     File::mkdir($this->db->motor()->getPath() . DS . 'cursors' . DS . $hash);
     if (empty($this->db->wheres)) {
         $ids = $this->db->motor()->ids('datas');
         foreach ($ids as $id) {
             $results[$id] = [];
         }
         unset($ids);
     } else {
         $results = $this->db->results;
     }
     $this->count = count($results);
     if (empty($results)) {
         File::rmdir($this->cursor);
         return true;
     } else {
         $index = 0;
         foreach ($results as $id => $row) {
             if (false !== $id) {
                 $file = $this->cursor . DS . $index . '.php';
                 $data = $this->db->motor()->read('datas.' . $id);
                 File::put($file, "<?php\nreturn " . var_export($data, 1) . ';');
                 $index++;
             }
         }
     }
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:42,代碼來源:Iterator.php

示例12: _buffer

 private static function _buffer($key, $data = null)
 {
     if (false === static::$_buffer) {
         return false;
     }
     $timeToBuffer = false !== static::$_cache ? static::$_cache * 60 : 2;
     $ext = false !== static::$_cache ? 'cache' : 'buffer';
     $file = CACHE_PATH . DS . $key . '_nosql.' . $ext;
     if (File::exists($file)) {
         $age = time() - File::modified($file);
         if ($age > $timeToBuffer) {
             File::delete($file);
         } else {
             return static::unserialize(static::load($file));
         }
     }
     if (null === $data) {
         return false;
     }
     File::put($file, static::serialize($data));
 }
開發者ID:schpill,項目名稱:thin,代碼行數:21,代碼來源:Data.php

示例13: compiled

 protected function compiled($compile = false)
 {
     $viewRedis = container()->getViewRedis();
     if (true !== $viewRedis) {
         $file = CACHE_PATH . DS . md5($this->_viewFile) . '.compiled';
         if (false !== $compile) {
             if (File::exists($file)) {
                 File::delete($file);
             }
             File::put($file, $this->makeCompile($compile));
         }
         return $file;
     } else {
         $redis = redis();
         $keyAge = sha1($this->_viewFile) . '::age';
         $keyTpl = sha1($this->_viewFile) . '::html';
         if (false !== $compile) {
             $redis->set($keyAge, time());
             $content = $this->makeCompile($compile);
             $redis->set($keyTpl, $content);
             return $content;
         } else {
             return $redis->get($keyTpl);
         }
     }
 }
開發者ID:schpill,項目名稱:thin,代碼行數:26,代碼來源:View.php

示例14: delete

 public function delete($k)
 {
     $tab = $this->unserialize(File::read($this->file));
     unset($tab[$k]);
     File::delete($this->file);
     File::put($this->file, $this->serialize($tab));
     return $this;
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:8,代碼來源:memcache.php

示例15: expire

 public function expire($key, $ttl = 0)
 {
     $key = $this->key($key);
     $ttl = 0 < $ttl ? $ttl + time() : $ttl;
     $file = $this->getFile($key);
     if (File::exists($file)) {
         $file = $this->getFile('expires.' . $ttl . '.' . $key);
         File::delete($file);
         File::put($file, '');
         return true;
     }
     return false;
 }
開發者ID:schpill,項目名稱:standalone,代碼行數:13,代碼來源:Caching.php


注:本文中的Thin\File::put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。