当前位置: 首页>>代码示例>>PHP>>正文


PHP File::append方法代码示例

本文整理汇总了PHP中File::append方法的典型用法代码示例。如果您正苦于以下问题:PHP File::append方法的具体用法?PHP File::append怎么用?PHP File::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


在下文中一共展示了File::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: w_serverlog

function w_serverlog($server, $log)
{
    $logfile = TMP . "server/" . $server . ".log";
    $file = new File($logfile);
    if ($file->exists()) {
        $file->append('
[' . date('Y-m-d H:i:s') . '] ' . $log);
    } else {
        $file->create();
        $file->append('[' . date('Y-m-d H:i:s') . '] ' . $log);
    }
}
开发者ID:Tim-NL,项目名称:SpaceBukkitPanel,代码行数:12,代码来源:serverlog.php

示例2: write

 /**
  * 
  * @param type $contents
  */
 public final function write()
 {
     $logFile = $this;
     $path = $logFile->getPath();
     $logHeader = $logFile->getLogHeader();
     $logContents = $logFile->logContents;
     $file = new File($path, true, 0777);
     $file->lock = true;
     $file->append($logHeader);
     $file->append("\n");
     $file->append($logContents);
     $file->append("\n\n");
     $file->close();
 }
开发者ID:Shiro-Nwal,项目名称:sin-kaisha-khine,代码行数:18,代码来源:AppLogFile.php

示例3: write

 /**
  * Write a message to the log file.
  *
  * <code>
  *		// Write an "error" message to the log file
  *		Log::write('error', 'Something went horribly wrong!');
  *
  *		// Write an "error" message using the class' magic method
  *		Log::error('Something went horribly wrong!');
  *
  *		// Log an arrays data
  *		Log::write('info', array('name' => 'Sawny', 'passwd' => '1234', array(1337, 21, 0)), true);
  *      //Result: Array ( [name] => Sawny [passwd] => 1234 [0] => Array ( [0] => 1337 [1] => 21 [2] => 0 ) )
  *      //If we had omit the third parameter the result had been: Array
  * </code>
  *
  * @param  string  $type
  * @param  string  $message
  * @return void
  */
 public static function write($type, $message, $pretty_print = false)
 {
     $message = $pretty_print ? print_r($message, true) : $message;
     // If there is a listener for the log event, we'll delegate the logging
     // to the event and not write to the log files. This allows for quick
     // swapping of log implementations for debugging.
     if (Event::listeners('laravel.log')) {
         Event::fire('laravel.log', array($type, $message));
     }
     $trace = debug_backtrace();
     foreach ($trace as $item) {
         if (isset($item['class']) and $item['class'] == __CLASS__) {
             continue;
         }
         $caller = $item;
         break;
     }
     $function = $caller['function'];
     if (isset($caller['class'])) {
         $class = $caller['class'] . '::';
     } else {
         $class = '';
     }
     $message = static::format($type, $class . $function . ' - ' . $message);
     File::append(path('storage') . 'logs/' . date('Y-m-d') . '.log', $message);
 }
开发者ID:gigikiri,项目名称:masjid-l3,代码行数:46,代码来源:log.php

示例4: report

 /**
  * Report all logger data with appropriate output
  *
  * @param   string Log file
  * @param   bool   Whether to write it or to return as array
  * @return  mixed
  */
 public static function report($logPath = '', $as_array = FALSE)
 {
     $logs = array();
     $profiler = self::$profiler;
     $log = self::$log;
     foreach ($log as $header => $content) {
         // Initial empty message
         $message = '';
         // @codeCoverageIgnoreStart
         if ($content->isEmpty()) {
             // Do nothing
         } else {
             // @codeCoverageIgnoreEnd
             // Iterate over all content and place as lines
             foreach ($content as $line) {
                 $timestamp = key($line);
                 $message .= $timestamp . '-' . $line[$timestamp] . '(' . $header . ')' . "\n";
             }
             $logs[] = $message;
         }
     }
     // Just log if there are something to report
     if (!empty($logs)) {
         $appPath = defined('PATH_APP') ? PATH_APP : '/tmp';
         $path = empty($logPath) ? $appPath . DIRECTORY_SEPARATOR . 'log_' . date('Y-m-d') . '.txt' : $logPath;
         if ($as_array) {
             return $logs;
         } else {
             $report = implode("\n", $logs);
             File::append($path, $report);
         }
     }
 }
开发者ID:nurcahyo,项目名称:juriya,代码行数:40,代码来源:Logger.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Get the Name and Value of the environment variable.
     $name = $this->argument('name');
     $value = $this->argument('value');
     // If the name of the environment variable has not been included, ask the user for it.
     if (empty($name)) {
         $name = $this->ask('What is the name of the environment variable?');
     }
     // If the value of the environment variable has not been included, ask the user for it.
     if (empty($value)) {
         $value = $this->ask('What is the value of the environment variable?');
     }
     // Append the new environment variable to the file.
     try {
         \File::get('.env');
         // Encrypt the value.
         $encrypted_value = Crypt::encrypt($value);
         // Append the value to the .env file.
         \File::append('.env', "\n{$name} = {$encrypted_value} ");
         // Display success message using the decrypted value of the encrypted value.
         $this->info('The environment variable named ' . $name . ' has been added with the value of ' . Crypt::decrypt($encrypted_value) . '. Please check that the value displayed is the supplied value.');
     } catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $e) {
         $this->error('Unable to load the .env file.');
     }
 }
开发者ID:baglerit,项目名称:envariable,代码行数:31,代码来源:EnVariableCommand.php

示例6: write

 public function write($str, $type = null)
 {
     $type = is_null($type) ? 'INFO' : $type;
     $type = Inflector::upper($type);
     $data = date('Y-m-d H:i:s') . ":{$type}:{$str}";
     File::append($this->file, $data . "\n");
 }
开发者ID:schpill,项目名称:standalone,代码行数:7,代码来源:log.php

示例7: write

 /**
  * Writes given message to a log file in the logs directory.
  *
  * @param string $type Type of log, becomes part of the log's filename
  * @param string $msg  Message to log
  * @return boolean Success
  */
 function write($type, $msg)
 {
     $filename = LOGS . $type . '.log';
     $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $msg . "\n";
     $log = new File($filename);
     return $log->append($output);
 }
开发者ID:carriercomm,项目名称:pastebin-5,代码行数:14,代码来源:cake_log.php

示例8: boot

 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     $events->listen('eloquent.saving: *', function ($model) {
         \File::append('audit', "Table {$model->getTable()} has been saved." . PHP_EOL);
     });
 }
开发者ID:threening,项目名称:laraseda,代码行数:13,代码来源:EventServiceProvider.php

示例9: handle

    /**
     * @inheritdoc
     */
    public function handle()
    {
        foreach ($this->dumper_config as $class => $file) {
            if (\File::exists($file)) {
                if (!$this->confirm("file {$file} exists, are you sure to OVERWRITE it? [y|N]")) {
                    continue;
                }
                \File::delete($file);
            }
            $instance = new $class();
            $config = FormDumper::dump($instance);
            $php = var_export($config, true);
            $now = date('Y-m-d H:i:s', time());
            $data = <<<DATA
<?php
/**
 * Created by FormDumper
 * Date: {$now}
 */

 return {$php};
DATA;
            \File::append($file, $data);
        }
    }
开发者ID:xjtuwangke,项目名称:laravel-bundles,代码行数:28,代码来源:FormDumpCommand.php

示例10: compileDir

 public static function compileDir($dir, $destFile)
 {
     $dh = opendir($dir);
     if (!$dh) {
         throw new Exception('Unknown dir: ' . $dir);
     }
     while ($file = readdir($dh)) {
         if ($file[0] == '.') {
             continue;
         }
         $absfile = Dir::normalize($dir) . $file;
         if (is_file($absfile) && File::getExtension($file) == 'js') {
             File::append($destFile, "//FILE: {$file}" . chr(10));
             if (filesize($absfile) > 200000) {
                 File::append($destFile, file_get_contents($absfile));
             } else {
                 File::append($destFile, self::minify($absfile));
             }
             File::append($destFile, chr(10) . chr(10));
         } else {
             if (is_dir($absfile)) {
                 self::compileDir($absfile, $destFile);
             }
         }
     }
     closedir($dh);
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:27,代码来源:Javascript.php

示例11: addAdminRouteGroup

 public function addAdminRouteGroup()
 {
     $content = \File::get(__DIR__ . '/../../templates/routes/adminRoutes.txt');
     $route_file = \File::get(app_path() . '/routes.php');
     if (!strpos($route_file, "'prefix' => 'admin'")) {
         \File::append(app_path() . '/routes.php', $content);
     }
 }
开发者ID:onesquarepixel,项目名称:mine,代码行数:8,代码来源:MineRepository.php

示例12: testWrite

 public function testWrite()
 {
     $file = new File('/tmp/test');
     $this->assertEquals(true, $file->append("test\n"));
     $this->assertEquals(true, $file->append("test\n"));
     $this->assertEquals(true, $file->copy('/tmp/test2'));
     $this->assertEquals(true, $file->delete());
     $file = new File('/tmp/test2');
     $linecount = 0;
     foreach ($file->lines() as $line) {
         $linecount = $linecount + 1;
     }
     $array = $file->toArray();
     $this->assertEquals(2, count($array));
     $this->assertEquals(2, $linecount);
     $this->assertEquals(true, $file->delete());
     $this->assertEquals(false, $file->isFile());
 }
开发者ID:seanyainkiranina,项目名称:completecontrol,代码行数:18,代码来源:filetest.class.php

示例13: onFinish

 public function onFinish()
 {
     if ($this->_queriesCount < $this->_limit) {
         return;
     }
     $filename = storage_path('/logs/query.' . date('d.m.y') . '.request.log');
     $string = '[' . date('H:i:s') . '] ' . \Request::fullUrl() . ': ' . $this->_queriesCount . ' queries in ' . $this->_totalTime . 'ms.' . PHP_EOL;
     \File::append($filename, $string);
 }
开发者ID:shenaar,项目名称:dbprofiler,代码行数:9,代码来源:RequestQueryHandler.php

示例14: generate

 /**
  * Cria o snapshot na pasta que esta configurada
  *
  * @return boolean
  */
 public function generate()
 {
     $this->Menu = ClassRegistry::init("Cms.Menu");
     $aDados = $this->Menu->find('all');
     if (!$this->isUpToDate($aDados)) {
         App::import("Helper", "Xml");
         App::import("File");
         $oXml = new XmlHelper();
         $oXml->header();
         $oXml->serialize($aDados);
         $oFile = new File(Configure::read('Cms.CheckPoint.menus') . time() . ".xml", true, 0777);
         $oFile->append($oXml->header());
         $oFile->append("<menus>");
         $oFile->append($oXml->serialize($aDados));
         $oFile->append("</menus>");
         return true;
     }
     return false;
 }
开发者ID:niltonfelipe,项目名称:e-cidade_transparencia,代码行数:24,代码来源:check_point.php

示例15: out

 /**
  * Outputs a single or multiple error messages to stderr. If no parameters
  * are passed outputs just a newline.
  *
  * @param mixed $message A string or a an array of strings to output
  * @param integer $newlines Number of newlines to append
  * @access public
  */
 function out($message = null, $newlines = 1)
 {
     if (is_array($message)) {
         $message = implode($this->nl(), $message);
     }
     $output = $message . $this->nl($newlines);
     if (isset($this->File) && $this->File->writable()) {
         $this->File->append($output);
     }
     return $output;
 }
开发者ID:nojimage,项目名称:sql_dumper,代码行数:19,代码来源:sql_dumper.php


注:本文中的File::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。