本文整理匯總了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();
}
}
示例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);
}
示例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;
}
示例4: nextId
private function nextId()
{
$id = File::read($this->ids);
File::delete($this->ids);
File::put($this->ids, $id + 1);
return (int) $id;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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;
}
示例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');
}
}
示例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);
}
}
示例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++;
}
}
}
}
示例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));
}
示例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);
}
}
}
示例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;
}
示例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;
}