laravel-ide-helper
laravel-ide-helper copied to clipboard
Fix post-update-cmd with --no-dev installs
Summary
When barryvdh/laravel-ide-helper is a dev dependency, it is not available with --no-dev
installs ("release builds"). Which will give errors if you add ide-helper:<..>
in post-update-cmd
or post-install-cmd
in composer.json
.
This fixes that by making an intermediate that checks for APP_ENV="local"
in .env
to automatically run ide-helper scripts.
This patch is related to: https://github.com/barryvdh/laravel-ide-helper/issues/794
Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update
- [ ] Misc. change (internal, infrastructure, maintenance, etc.)
Checklist
- [ ] Existing tests have been adapted and/or new tests have been added
- [ ] Add a CHANGELOG.md entry
- [x] Update the README.md
- [ ] Code style has been fixed via
composer fix-style
It does not check if the database is available.
Somebody may want to implement something along the lines of:
try {
\Illuminate\Support\Facades\DB::connection()->getPdo();
} catch (Exception $e) {
// If we get here we are not connected
$this->comment($this->signature . ': No database connection, not updating PhpStorm ide-helper:* files.');
}
Our setup connects to multiple databases, and as dev you'd rather see it break than become silent.
Potentially ide-helper could drop such a file? I believe there are recommended ways to 'install files' in Laravel, e.g. to install config/<..>.php
I see class_exists()
could also be a nice test.
Is there some Laravel-ish, or Composer-ish way to see if ide-helper is loaded? And which class to test?
This should check whether ide-helper is installed:
Artisan::command('ide-helper:run', function () {
if (App::has('command.ide-helper.generate')) {
Artisan::call('ide-helper:meta', [], $this->output);
Artisan::call('ide-helper:generate', [], $this->output);
}
})->describe('Run ide-helper:generate and meta.');
This can be inserted to routes/console.php