Installation
Add the bundle to your composer.json:
composer require chameleon-system/upgrade-helper
Enable the bundle in config/bundles.php (Symfony) or config/app.php (Laravel via Symfony bridge):
return [
// ...
ChameleonSystem\UpgradeHelperBundle\ChameleonSystemUpgradeHelperBundle::class => ['all' => true],
];
First Run Execute the command with your Laravel project's root directory (adjust path as needed):
php artisan ch:upgr /path/to/your/laravel/project/app
(Note: Laravel users may need to alias the Symfony command via artisan or create a custom artisan command wrapper.)
Expected Output The tool scans for:
$container->get($serviceVar) where $serviceVar is dynamic).$container->get('non.public.service')).Before upgrading to Chameleon System 7.1, run the helper to identify:
ServiceLocator usage).CI/CD Pipeline Add the command to your pre-upgrade checks (e.g., GitHub Actions):
- name: Run Upgrade Helper
run: php artisan ch:upgr app
Fail the build if warnings are found (customize exit codes if needed).
Local Development Run during feature branches or before major upgrades:
php artisan ch:upgr app --format=json > upgrade_report.json
(Use --format=json for programmatic parsing.)
Service Locator Replacement
If using ServiceLocator, the helper flags non-public services. Refactor to:
// Before (flagged)
$service = $locator->get('non.public.service');
// After (public service or DI)
$service = app()->make(PublicService::class);
Service Container Access
Laravel’s app() helper or Illuminate\Container\Container is scanned. Example:
// Flagged: Non-public service
$userRepo = app('user.repository');
// Fixed: Use binding or public service
$userRepo = app()->make(UserRepository::class);
Dynamic Service Names
Implicit calls (e.g., $container->get($dynamicKey)) require manual review. Mitigate by:
Custom Artisan Command (Optional) Extend the bundle’s command for Laravel:
// app/Console/Commands/UpgradeHelper.php
namespace App\Console\Commands;
use Symfony\Component\Console\Application;
class UpgradeHelper extends Command {
protected $signature = 'upgrade:helper {path}';
public function handle() {
$symfonyApp = new Application();
$symfonyApp->add(new \ChameleonSystem\UpgradeHelperBundle\Command\UpgradeHelperCommand());
$symfonyApp->run();
}
}
False Positives
$container->get($var)) may not be actionable. Verify manually.Laravel-Specific Quirks
app() helper may not map 1:1 to Symfony’s ContainerInterface.$container directly.Exit Codes
The command exits with 0 (success) even if warnings exist. Override in Laravel:
// In your custom command
if ($this->hasErrors()) {
return 1; // Fail build
}
Verbose Output
Use -v or -vv for detailed paths:
php artisan ch:upgr app -vv
JSON Output Parse warnings programmatically:
php artisan ch:upgr app --format=json | jq '.warnings[] | select(.type == "non_public")'
Exclude Directories Ignore tests or third-party code:
php artisan ch:upgr app --exclude="tests,vendor"
Custom Service Whitelisting
Extend the bundle to ignore known-safe services (e.g., config('services.allowed')).
Post-Processing Scripts
Use the JSON output to auto-fix simple cases (e.g., replace app('service') with app()->make(Service::class)).
Symfony Event Listeners
Hook into kernel.terminate to log warnings to a database or Slack.
Note: The package is Symfony-focused but can be adapted for Laravel with minor wrappers. Prioritize manual review for implicit calls.
How can I help you explore Laravel packages today?