本文整理匯總了PHP中Illuminate\Support\Facades\File::append方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::append方法的具體用法?PHP File::append怎麽用?PHP File::append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\File
的用法示例。
在下文中一共展示了File::append方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateUpIndex
/**
* @param $name
* @param $type
* @param $path
* @throws Exception
* @throws FileNotFoundException
*/
public function updateUpIndex($name, $type, $path)
{
$indexPath = "{$path}/../index.ts";
$statement = "export * from './" . $name . "';\n";
$fileContent = File::get($indexPath);
// Clean up the new line characters as different operating
// systems put different characters for line breaks.
$fileContent = str_replace(["\r", "\n"], '', $fileContent);
$fileContent = explode(';', $fileContent);
$fileContent = implode(";\n", $fileContent);
File::delete($indexPath);
File::append($indexPath, $fileContent . $statement);
$this->info("Updated {$this->normalize($path . "./../index.ts")}.");
}
示例2: handle
/**
* Execute the command.
*/
public function handle()
{
$name = $this->argument('name');
$domain = $this->argument('domain');
$webExecution = $this->option('webExecution');
try {
$workingPath = base_path('../');
$outputFolder = strtolower(str_replace(' ', '-', $name . '-api'));
$this->writeStatus('Installing lumen and dependencies ...', $webExecution);
// Create project
(new Composer($workingPath))->createProject('laravel/lumen', '5.1.*', $outputFolder)->setWorkingPath($workingPath . $outputFolder)->requirePackage('dingo/api', '1.0.x@dev');
$this->writeStatus('Setting up lumen ...', $webExecution);
// Rename .env file
File::move($workingPath . $outputFolder . '/.env.example', $workingPath . $outputFolder . '/.env');
// Dingo config
File::append($workingPath . $outputFolder . '/.env', 'API_DOMAIN=' . $domain . PHP_EOL . 'API_STANDARDS_TREE=vnd' . PHP_EOL . 'API_SUBTYPE=' . strtolower(str_replace(' ', '', $name)) . PHP_EOL . 'API_VERSION=v1' . PHP_EOL . 'API_NAME="' . $name . '"' . PHP_EOL . 'API_CONDITIONAL_REQUEST=false' . PHP_EOL . 'API_STRICT=false' . PHP_EOL . 'API_DEFAULT_FORMAT=json' . PHP_EOL . 'API_DEBUG=true');
// Get lumen app file
$lumenAppFile = File::get($workingPath . $outputFolder . '/bootstrap/app.php');
// Get .env file
$lumenEnvFile = File::get($workingPath . $outputFolder . '/.env');
// Enable Dotenv
$lumenAppFile = str_replace('// Dotenv::load(__DIR__.\'/../\');', 'Dotenv::load(__DIR__.\'/../\');', $lumenAppFile);
// Enable Eloquent
$lumenAppFile = str_replace('// $app->withEloquent();', '$app->withEloquent();', $lumenAppFile);
// Add Dingo service provider
$registerServiceProviderPosition = strpos($lumenAppFile, 'Register Service Providers');
$lumenAppFile = substr($lumenAppFile, 0, $registerServiceProviderPosition + 322) . '$app->register(Dingo\\Api\\Provider\\LumenServiceProvider::class);' . substr($lumenAppFile, $registerServiceProviderPosition + 320);
// Database config
$lumenEnvFile = str_replace('DB_DATABASE=homestead', 'DB_DATABASE=' . env('DB_DATABASE', 'homestead'), $lumenEnvFile);
$lumenEnvFile = str_replace('DB_USERNAME=homestead', 'DB_USERNAME=' . env('DB_USERNAME', 'homestead'), $lumenEnvFile);
$lumenEnvFile = str_replace('DB_PASSWORD=secret', 'DB_PASSWORD=' . env('DB_PASSWORD', 'secret'), $lumenEnvFile);
File::put($workingPath . $outputFolder . '/.env', $lumenEnvFile);
File::put($workingPath . $outputFolder . '/bootstrap/app.php', $lumenAppFile);
} catch (\Exception $exception) {
$this->writeStatus('Error', $webExecution);
Log::error($exception->getMessage());
}
}
示例3: generateAll
//.........這裏部分代碼省略.........
foreach ($mw['routes'] as $r => $route) {
$contentRoutes .= " Route::resource('" . $route['path'] . "' , '" . $route['controller'] . "');";
$contentRoutes .= "\n";
}
/* NAMESPACES MIDDLEWARES ROUTES */
$contentRoutes .= ' });';
$contentRoutes .= "\n";
}
/* NAMESPACES MIDDLEWARES */
/* NAMESPACES ROUTES */
foreach ($ns['routes'] as $r => $route) {
$contentRoutes .= " Route::resource('" . $route['path'] . "' , '" . $route['controller'] . "');";
$contentRoutes .= "\n";
}
/* NAMESPACES ROUTES */
$contentRoutes .= '});';
$contentRoutes .= "\n";
}
/* NAMESPACES */
/* PREFIXES */
foreach ($router['prefixes'] as $prefix => $p) {
$contentRoutes .= "Route::group(['prefix' => '" . $prefix . "'";
$contentRoutes .= '] , function() {';
$contentRoutes .= "\n";
/* PREFIXES MIDDLEWARES */
foreach ($p['middlewares'] as $middleware => $mw) {
$middleware = "['" . str_replace(',', "','", $middleware) . "']";
$contentRoutes .= " Route::group(['middleware' => " . $middleware;
$contentRoutes .= '] , function() {';
$contentRoutes .= "\n";
/* PREFIXES MIDDLEWARES ROUTES */
foreach ($mw['routes'] as $r => $route) {
$contentRoutes .= " Route::resource('" . $route['path'] . "' , '" . $route['controller'] . "');";
$contentRoutes .= "\n";
}
/* PREFIXES MIDDLEWARES ROUTES */
$contentRoutes .= ' });';
$contentRoutes .= "\n";
}
/* PREFIXES MIDDLEWARES */
/* PREFIXES ROUTES */
foreach ($p['routes'] as $r => $route) {
$contentRoutes .= " Route::resource('" . $route['path'] . "' , '" . $route['controller'] . "');";
$contentRoutes .= "\n";
}
/* PREFIXES ROUTES */
$contentRoutes .= '});';
$contentRoutes .= "\n";
}
/* PREFIXES */
/* MIDDLEWARES */
foreach ($router['middlewares'] as $middleware => $mw) {
$middleware = "['" . str_replace(',', "','", $middleware) . "']";
$contentRoutes .= "Route::group(['middleware' => " . $middleware;
$contentRoutes .= '] , function() {';
$contentRoutes .= "\n";
/* MIDDLEWARES ROUTES */
foreach ($mw['routes'] as $r => $route) {
$contentRoutes .= " Route::resource('" . $route['path'] . "' , '" . $route['controller'] . "');";
$contentRoutes .= "\n";
}
/* MIDDLEWARES ROUTES */
$contentRoutes .= '});';
$contentRoutes .= "\n";
}
/* MIDDLEWARES */
/* ROUTES */
foreach ($router['routes'] as $r => $route) {
$contentRoutes .= "Route::resource('" . $route['path'] . "' , '" . $route['controller'] . "');";
$contentRoutes .= "\n";
}
/* ROUTES */
$contentRoutes .= "\n";
$contentRoutes .= $delimiter;
$contentRoutes .= "\n";
$lines = file($file);
$init = false;
$preInit = false;
$end = false;
$content = "";
foreach ($lines as $l => $line) {
if ($preInit) {
$init = true;
}
if (strpos($line, $delimiter) !== false) {
$preInit = true;
}
if (($init || $preInit) && !$end) {
$content .= $line;
}
if (strpos($line, $delimiter) !== false && $init) {
$end = true;
}
}
if ($init && $end) {
return File::put($file, str_replace($content, $contentRoutes, file_get_contents($file)));
} else {
return File::append($file, $contentRoutes);
}
}
示例4: _pack
/**
* Packing files
*
*/
private function _pack()
{
//Get package
$packages = Config::get('minify::minify.css.packages');
//If we don't have packages to scan
if (empty($packages)) {
$this->error('No CSS packages to create');
return false;
}
foreach ($packages as $package => $files) {
$package = $this->_assetsDirectory . '/' . $package;
//
$this->info("Packing " . $package);
// Delete file first
File::delete($package);
foreach ($files as $file) {
$file = $this->_assetsDirectory . '/' . $file;
$this->line("\tAppending " . $file . "...");
File::append($package, File::get($file));
}
}
return true;
}
示例5: store
/**
* Store the compiled stub.
*
* @param $modelName
* @param \stdClass $scaffolderConfig
* @param $compiled
* @param \Scaffolder\Support\FileToCompile $fileToCompile
*
* @return mixed|void
*/
protected function store($modelName, stdClass $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
{
File::append(PathParser::parse($scaffolderConfig->paths->routes), PHP_EOL . $compiled);
}
示例6: storeToCache
/**
* @param $content
*
* stores content to cache based on cache key
*/
public function storeToCache($content)
{
if ($content === null) {
$content = 'null';
}
if ($this->cache && $this->cacheKey) {
if ($this->cacheTime > 0) {
Cache::put($this->cacheKey, $content, $this->cacheTime);
} else {
Cache::forever($this->cacheKey, $content);
}
if (!File::exists($this->keyStorePath)) {
File::put($this->keyStorePath, $this->cacheKey . "\n");
} else {
File::append($this->keyStorePath, $this->cacheKey . "\n");
}
}
}
示例7: query
public function query($id)
{
if (!empty($id)) {
$users = $this->entry->select('*')->join('projects', 'projects.id', '=', 'entries.project_id')->join('entry_free', 'entries.id', '=', 'entry_free.entry_id')->join('frees', 'entry_free.free_id', '=', 'frees.id')->where('projects.id', $id)->get();
if ($users->count() > 0) {
$entry = $this->entry->find($id);
$protocol = $entry->project->protocol->protocol_number;
$file = 'export_frees/01757321000106_' . $protocol . '_' . date('dmY') . '_001.txt';
foreach ($users as $user) {
$contents = $user->nome . ';' . $user->nis . ';' . $user->datadenascimento . ';' . $user->sexo . ';' . $user->num_identid_rg . ';' . $user->dt_identid_rg . ';' . $user->sg_em_identid_rg . ';' . $user->cpf . ';' . $user->nomedamae . ";\r\n";
$bytes_written = File::append($file, $contents);
if ($bytes_written === false) {
die("Error writing to file");
}
}
return $file;
}
}
}
示例8: store
/**
* Store the compiled stub.
*
* @param $modelName
* @param \stdClass $scaffolderConfig
* @param $compiled
* @param \Scaffolder\Support\FileToCompile $fileToCompile
*
* @return mixed|void
*/
protected function store($modelName, stdClass $scaffolderConfig, $compiled, FileToCompile $fileToCompile)
{
File::append(base_path('../' . strtolower(str_replace(' ', '-', $scaffolderConfig->name . '-api'))) . '/app/Http/routes.php', PHP_EOL . $compiled);
}
示例9: date
/**
*
* Logging operation - to a file (upload_log.txt) and to the stdout
* @param string $str - the logging string
*/
function _log($str)
{
$log_str = date('d.m.Y') . ": {$str}\r\n";
File::append($this->tempDirectory . 'upload_log.txt', $log_str);
}