本文整理汇总了PHP中File::put方法的典型用法代码示例。如果您正苦于以下问题:PHP File::put方法的具体用法?PHP File::put怎么用?PHP File::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$path = $this->getFilePath();
$directory = dirname($path);
if ($this->file->exists($path)) {
$this->error("A view already exists at {$path}!");
return false;
}
if (!$this->file->exists($directory)) {
$this->file->makeDirectory($directory, 0777, true);
}
$this->file->put($path, $this->getViewContents());
$this->info("Created a new view at {$path}");
}
示例2: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//borrramos generaciones previas
File::deleteDirectory(app_path('modelos_generados'));
//creamos el directorio en app..
File::makeDirectory(app_path('modelos_generados'), 777);
$tablas = SchemaHelper\Table::getTablesCurrentDatabase();
$this->info("Buscando tablas..");
foreach ($tablas as $tabla) {
$this->info("Generando Modelo de la tabla: " . $tabla->table_name);
//class name
$class_name = ucfirst(camel_case(str_singular_spanish($tabla->table_name)));
$baseString = File::get(app_path('models/Schema/Template.txt'));
//replace class name..
$baseString = str_replace('@class_name@', $class_name, $baseString);
//replace table name..
$baseString = str_replace('@table_name@', $tabla->table_name, $baseString);
//replace pretty name..
$baseString = str_replace('@pretty_name@', $tabla->table_name, $baseString);
//find columns.
$columns = $tabla->columns()->whereNotIn('column_name', static::$common_hidden)->get();
//generate fillable
$baseString = str_replace('@fillable@', $this->generarFillable($columns), $baseString);
//generate pretty fields string.
$baseString = str_replace('@pretty_fields@', $this->generarPrettyFields($columns), $baseString);
//generate rules..
$baseString = str_replace('@rules@', $this->genenarRules($columns), $baseString);
//generate belongs to..
$baseString = str_replace('@belongs_to@', $this->generarBelongsTo($columns), $baseString);
File::put(app_path('modelos_generados/' . $class_name . '.php'), $baseString);
}
$this->info("Generación terminada.");
}
示例3: __destruct
public function __destruct()
{
if (true === $this->collection()->write) {
File::delete($this->file);
File::put($this->file, serialize($this->collection()->collection()));
}
}
示例4: getFile
public function getFile($lang = false, $module = false)
{
// dd(view()->shared('controller'));
// app('request')->attributes->get('controller');
if (!$lang) {
$lang = \App::getLocale();
}
// Busca o arquivo especificado
$cfg_file = mkny_lang_path($lang . '/' . $module) . '.php';
// Field types
$f_types = array_unique(array_values(app()->make('Mkny\\Cinimod\\Logic\\AppLogic')->_getFieldTypes()));
// Se o diretorio nao existir
if (!realpath(dirname($cfg_file))) {
\File::makeDirectory(dirname($cfg_file));
}
// Config file data
if (!\File::exists($cfg_file)) {
\File::put($cfg_file, "<?php return array( 'teste' => 'teste' );");
}
// Arquivo aberto
$config_str = \File::getRequire($cfg_file);
$arrFields = array();
foreach ($config_str as $field_name => $field_value) {
if (!is_string($field_value)) {
$arrFields[$field_name] = array('name' => $field_name, 'trans' => $field_name, 'values' => $field_value, 'type' => 'multi');
} else {
$arrFields[$field_name] = array('name' => $field_name, 'trans' => $field_name, 'default_value' => $field_value, 'type' => 'string');
}
}
return view('cinimod::admin.generator.trans_detailed')->with(['form' => app()->make('\\Mkny\\Cinimod\\Logic\\FormLogic', [['fields-default-class' => 'form-control']])->getForm(false, action('\\' . get_class($this) . '@postFile', [$lang, $module]), $arrFields, $module)]);
}
示例5: go
public function go()
{
//$feed = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/_add-ons/wordpress/wp_posts.xml');
//$items = simplexml_load_string($feed);
$posts_object = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . '/_add-ons/wordpress/roobottom_old_posts.xml');
$posts = object_to_array($posts_object);
$yaml_path = $_SERVER['DOCUMENT_ROOT'] . '/_content/01-blog/';
foreach ($posts['table'] as $post) {
if ($post['column'][8] == "publish") {
$slug = Slug::make($post['column'][5]);
$slug = preg_replace('/[^a-z\\d]+/i', '-', $slug);
if (substr($slug, -1) == '-') {
$slug = substr($slug, 0, -1);
}
$date = date('Y-m-d-Hi', strtotime($post['column'][3]));
$file = $date . "-" . $slug . ".md";
if (!File::exists($yaml_path . $file)) {
$yaml = [];
$yaml['title'] = $post['column'][5];
$content = $post['column'][4];
$markdown = new HTML_To_Markdown($content, array('header_style' => 'atx'));
File::put($yaml_path . $file, YAML::dump($yaml) . '---' . "\n" . $markdown);
}
echo $slug . "-" . $date;
echo "<br/><hr/><br/>";
}
}
return "ok";
}
示例6: replaceCurrentConnection
/**
* @param $current_connection
* @param $config_file_path
* @return string
*/
function replaceCurrentConnection($current_connection, $config_file_path)
{
$connection_under_test = "'default' => '{$current_connection}'";
$content = preg_replace("/'default' => '[a-zA-Z]*'/", $connection_under_test, File::get($config_file_path));
File::put($config_file_path, $content);
return $connection_under_test;
}
示例7: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (file_exists($compiled = base_path() . '/bootstrap/compiled.php')) {
$this->error('Error generating IDE Helper: first delete bootstrap/compiled.php (php artisan clear-compiled)');
} else {
$filename = $this->argument('filename');
if ($this->option('memory')) {
$this->useMemoryDriver();
}
$this->extra = \Config::get('laravel-ide-helper::extra');
$this->magic = \Config::get('laravel-ide-helper::magic');
if ($this->option('helpers') || \Config::get('laravel-ide-helper::include_helpers')) {
$this->helpers = \Config::get('laravel-ide-helper::helper_files');
} else {
$this->helpers = array();
}
$content = $this->generateDocs();
$written = \File::put($filename, $content);
if ($written !== false) {
$this->info("A new helper file was written to {$filename}");
} else {
$this->error("The helper file could not be created at {$filename}");
}
}
}
示例8: run
public function run()
{
DB::table('home_page')->delete();
$success = File::cleanDirectory($this->getImagesPath());
File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore'));
HomePage::create(['headline' => "Industrial Legacy", 'text' => 'RUSTIC DETAILS. MODERN EDGE. REFINED LIVING IN COURT SQUARE. <br> 1 - 4 BEDROOM HOMES FROM $615K. PENTHOUSES PRICED UPON REQUEST.', 'subtext' => 'CHILDREN\'S PLAYROOM, LOUNGE, LIBRARY, GYM, TERRACE AND PARKING', 'image' => $this->copyImage(public_path() . '/backup_images/building/building.jpg')]);
}
示例9: instance
public static function instance($model, $db = null, $options = [])
{
$db = is_null($db) ? SITE_NAME : $db;
$class = __NAMESPACE__ . '\\Model\\' . ucfirst(Inflector::lower($model));
$file = APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . ucfirst(Inflector::lower($db)) . DS . ucfirst(Inflector::lower($model)) . '.php';
if (File::exists($file)) {
require_once $file;
return new $class();
}
if (!class_exists($class)) {
$code = 'namespace ' . __NAMESPACE__ . '\\Model;' . "\n" . '
class ' . ucfirst(Inflector::lower($model)) . ' extends \\Thin\\MyOrm
{
public $timestamps = false;
protected $table = "' . Inflector::lower($model) . '";
public static function boot()
{
static::unguard();
}
}';
if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql')) {
$dir = APPLICATION_PATH . DS . 'models' . DS . 'Mysql';
File::mkdir($dir);
}
if (!is_dir(APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . ucfirst(Inflector::lower($db)))) {
$dir = APPLICATION_PATH . DS . 'models' . DS . 'Mysql' . DS . ucfirst(Inflector::lower($db));
File::mkdir($dir);
}
File::put($file, '<?php' . "\n" . $code);
require_once $file;
return new $class();
}
}
示例10: run
public function run()
{
DB::table('filter_images')->delete();
$success = File::cleanDirectory($this->getImagesPath());
File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore'));
// Create images for all filters. In this phase images for all the filter will be the same
$filters = Filter::all();
foreach ($filters as $filter) {
FilterImage::create(['filter_id' => $filter->id, 'image_name' => $this->copyImage(public_path() . '/backup_images/filters/gym.jpg')]);
// FilterImage::create([
// 'filter_id' => $filter->id,
// 'image_name' => $this->copyImage(public_path().'/backup_images/filters/hero.jpg')
// ]);
//
// FilterImage::create([
// 'filter_id' => $filter->id,
// 'image_name' => $this->copyImage(public_path().'/backup_images/filters/kitchen.jpg')
// ]);
//
// FilterImage::create([
// 'filter_id' => $filter->id,
// 'image_name' => $this->copyImage(public_path().'/backup_images/filters/living.jpg')
// ]);
}
}
示例11: generateModels
function generateModels()
{
foreach ($this->entities as $entity) {
$model = View::make("generator.model", ['entity' => $entity, 'entity_name' => $entity->name . "Base", 'php_strart' => '<?php', 'brace_strart' => '{', 'brace_end' => '}'])->render();
File::put(app_path() . "/models/base/" . $entity->name . "Base.php", $model);
}
}
示例12: control_panel__add_routes
public function control_panel__add_routes()
{
$app = \Slim\Slim::getInstance();
$app->get('/globes', function () use($app) {
authenticateForRole('admin');
doStatamicVersionCheck($app);
Statamic_View::set_templates(array('globes-overview'), __DIR__ . '/templates');
$data = $this->tasks->getThemeSettings();
$app->render(null, array('route' => 'globes', 'app' => $app) + $data);
})->name('globes');
// Update global vars
$app->post('/globes/update', function () use($app) {
authenticateForRole('admin');
doStatamicVersionCheck($app);
$data = $this->tasks->getThemeSettings();
$vars = Request::fetch('pageglobals');
foreach ($vars as $name => $var) {
foreach ($data['globals'] as $key => $item) {
if ($item['name'] === $name) {
$data['globals'][$key]['value'] = $var;
}
}
}
File::put($this->tasks->getThemeSettingsPath(), YAML::dump($data, 1));
$app->flash('success', Localization::fetch('update_success'));
$app->redirect($app->urlFor('globes'));
});
}
示例13: setupDatabase
/**
* Create SQLite Database and Migrate everything
* @return void
*/
public function setupDatabase()
{
if (!File::exists(storage_path('database.sqlite'))) {
File::put(storage_path('database.sqlite'), '');
}
Artisan::call('migrate:refresh');
}
示例14: sendOrders
public function sendOrders()
{
set_time_limit(60000);
try {
$user = User::find(5);
if ($user->u_priase_count == 0) {
throw new Exception("已经执行过了", 30001);
} else {
$user->u_priase_count = 0;
$user->save();
}
$str_text = '恭喜“双11不怕剁手”众筹活动已成功,您被众筹发起者选中,请于12日18时前凭此信息到零栋铺子领取众筹回报。4006680550';
$str_push = '恭喜“双11不怕剁手”众筹活动已成功,您被众筹发起者选中,请于12日18时前凭此信息到零栋铺子领取众筹回报。4006680550';
$orders = Order::selectRaw('right(`t_orders`.`o_number`, 4) AS seed, `t_orders`.*')->join('carts', function ($q) {
$q->on('orders.o_id', '=', 'carts.o_id');
})->where('carts.c_type', '=', 2)->where('carts.p_id', '=', 4)->orderBy('seed', 'DESC')->limit(111)->get();
foreach ($orders as $key => $order) {
if (empty($order)) {
continue;
}
$phones = $order->o_shipping_phone;
$pushObj = new PushMessage($order->u_id);
$pushObj->pushMessage($str_push);
echo 'pushed to ' . $order->u_id . ' </br>';
$phoneObj = new Phone($order->o_shipping_phone);
$phoneObj->sendText($str_text);
echo 'texted to ' . $order->o_shipping_phone . ' </br>';
}
File::put('/var/www/qingnianchuangke/phones', implode(',', $phones));
$re = Tools::reTrue('发送中奖信息成功');
} catch (Exception $e) {
$re = Tools::reFalse($e->getCode(), '发送中奖信息失败:' . $e->getMessage());
}
return Response::json($re);
}
示例15: run
public function run()
{
DB::table('availability_page')->delete();
$success = File::cleanDirectory($this->getImagesPath());
File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore'));
AvailabilityPage::create(['image_name' => ""]);
}