/**
* 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();
}
$helpers = '';
if ($this->option('helpers') || $this->config->get('laravel-ide-helper::include_helpers')) {
foreach ($this->config->get('laravel-ide-helper::helper_files', array()) as $helper) {
if (file_exists($helper)) {
$helpers .= str_replace(array('<?php', '?>'), '', $this->files->get($helper));
}
}
} else {
$helpers = '';
}
$generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers);
$content = $generator->generate();
$written = $this->files->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}");
}
}
}