Barryvdh\LaravelIdeHelper\Generator::generate PHP Method

generate() public method

Generate the helper file contents;
public generate ( string $format = 'php' ) : string;
$format string The format to generate the helper in (php/json)
return string;
    public function generate($format = 'php')
    {
        // Check if the generator for this format exists
        $method = 'generate' . ucfirst($format) . 'Helper';
        if (method_exists($this, $method)) {
            return $this->{$method}();
        }
        return $this->generatePhpHelper();
    }

Usage Example

コード例 #1
0
 /**
  * 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}");
         }
     }
 }
All Usage Examples Of Barryvdh\LaravelIdeHelper\Generator::generate