fi/osbundle
OsBundle (fi/osbundle) is a Symfony bundle providing integration components for Comune di Firenze projects. Install via Composer and add PSR-4 autoload mapping Fi\OsBundle\ to vendor/fi/osbundle, then require version 2.0.*.
OsBundle is a lightweight, OS-specific utility bundle for Laravel/Symfony, targeting system-level operations (e.g., OS detection, environment checks, or platform-specific configurations). It aligns well with projects requiring cross-platform compatibility or OS-aware logic (e.g., CLI tools, deployment scripts, or feature flags).AppServiceProvider binding vs. Symfony’s services.yaml).Storage facade interactions) may surface post-integration.OsBundle services into controllers), integration may require reverse-engineering Symfony bundle conventions.php_uname(), DIRECTORY_SEPARATOR) or Laravel helpers (config(), env())?ContainerInterface? If so, how will it integrate with Laravel’s Illuminate\Container\Container?OsService Facade)?Artisan for CLI OS checks.symfony/process for OS-agnostic process management.ServiceProvider to bind Symfony services (e.g., OsBundle\Detector).OsFacade (e.g., Os::isWindows()).config/packages/os.yaml; Laravel would need manual config/os.php migration.PHP_OS), so no additional extensions are required.composer require fi/osbundle:^2.0.tinker session:
$detector = app()->make('Fi\OsBundle\Detector');
$detector->getOsName(); // e.g., "Linux", "Windows"
OsServiceProvider to:
Os::isMac()).// app/Providers/OsServiceProvider.php
use Fi\OsBundle\Detector;
use Illuminate\Support\Facades\Facade;
class OsServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton(Detector::class, function ($app) {
return new Detector();
});
}
}
// app/Facades/Os.php
namespace App\Facades;
use Illuminate\Support\Facades\Facade as LaravelFacade;
class Os extends LaravelFacade {
protected static function getFacadeAccessor() {
return 'Fi\OsBundle\Detector';
}
}
os.yaml to Laravel’s config/os.php (if bundle uses config).config/os.php:
return [
'platforms' => [
'windows' => ['Windows', 'WINNT'],
'linux' => ['Linux'],
],
];
public function handle($request, Closure $next) {
if (Os::isWindows()) {
return redirect()->route('windows.dashboard');
}
return $next($request);
}
if (Os::isMac()) {
Artisan::call('cache:clear');
}
Detector into services:
use Fi\OsBundle\Detector;
class MyService {
public function __construct(private Detector $detector) {}
public function doOsSpecificWork() {
if ($this->detector->isLinux()) {
// Linux logic
}
}
}
2.0.*), which aligns with Laravel 8+ (Symfony 5.x). Risk: May need polyfills for older Laravel versions (e.g., 7.x).composer.json for PHP version constraints (likely ^7.4 or ^8.0). Ensure project’s php-version in composer.json matches.symfony/dependency-injection). Use composer why-not fi/osbundle to preempt issues.ServiceProvider, test basic OS detection.config/os.php.composer.json, test). Risk: Breaking changes if Symfony dependencies update (e.g., symfony/dependency-injection).ServiceProvider/Facade layer may need updates if the underlying bundle API changes.Os::isWindows()) in project’s wiki or inline PHPDoc.ContainerInterface could complicate future migrations away from the bundle.How can I help you explore Laravel packages today?