Last active
March 15, 2018 13:51
-
-
Save Caffe1neAdd1ct/da1589e3af6bb0341caef666692ca9a9 to your computer and use it in GitHub Desktop.
Artisan IDE Helper Generate On Laravel 4.2 Local Env Only + NetBeans ide_helper_models rewrite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Console\Command; | |
/** | |
* Run IDE generation through artisan when on the local environment. | |
* This should only be called by composer install/update. | |
* | |
* @author Kevin Andrews <[email protected]> | |
*/ | |
class ComposerDevelopment extends Command | |
{ | |
protected $name = 'composer:development'; | |
protected $description = 'Run post-composer install commands'; | |
public function fire() | |
{ | |
if($this->laravel->environment('local')) { | |
$this->call('ide-helper:models', ['--nowrite' => true]); | |
$this->call('ide-helper:meta'); | |
$this->call('ide-helper:generate'); | |
$this->call('composer:netbeans'); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Console\Command; | |
use Illuminate\Filesystem\Filesystem; | |
/** | |
* Modify Generated IDE Helper Files for compatibility with NetBeans | |
* | |
* @author Kevin Andrews <[email protected]> | |
*/ | |
class ComposerIdeHelperNetbeans extends Command | |
{ | |
protected $name = 'composer:netbeans'; | |
protected $description = 'Run post-composer netbeans ide helper compatability commands'; | |
/** | |
* Removes class references on @method static hints | |
*/ | |
public function fire() | |
{ | |
if(!$this->laravel->environment('local')) { | |
$this->info($this->name . ' App not running locally, refusing to run netbeans autocomplete helper.'); | |
return true; | |
} | |
$ideHelperModelFilePath = base_path('_ide_helper_models.php'); | |
if(!File::exists($ideHelperModelFilePath)) { | |
$this->error($this->name . ' Helper Models file unavailable: ' . $ideHelperModelFilePath); | |
return false; | |
} | |
$content = File::get($ideHelperModelFilePath); | |
if(!$content) { | |
$this->error('Failed to retrieve file content ' . $ideHelperModelFilePath); | |
return false; | |
} | |
$newContent = preg_replace("/\@method static \\\\(.*)\s([a-zA-Z0-9]+)\((.*)\)/", "$2($3)", $content); | |
$writeResult = File::put($ideHelperModelFilePath, $newContent); | |
if(!$writeResult) { | |
$this->error('Failed to write new content to ' . $ideHelperModelFilePath); | |
return false; | |
} | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
composer.json: