- Can I use this bundle directly in Laravel, or is it only for Symfony?
- This bundle is designed for Symfony but can be adapted to Laravel with minimal effort. You’ll need to create a Laravel ServiceProvider to register the bundle’s services and translate Symfony-specific container calls to Laravel’s `app()` or `make()` methods. The core WireGuard logic (key generation, peer management) will work unchanged.
- How do I install and set up this bundle in a Laravel project?
- Run `composer require dimkinthepro/wireguard-bundle`, then create a Laravel ServiceProvider to load the bundle. Override Symfony’s `ContainerInterface` with Laravel’s container and publish the bundle’s config (if any) using `php artisan vendor:publish`. Check for CLI dependencies like `wg` and ensure they’re available in your environment.
- Does this bundle support generating WireGuard keys and configurations programmatically?
- Yes, the bundle provides utilities to generate WireGuard keys (private/public) and create peer configurations. You can use facades or services like `Wireguard::generateKey()` or `Wireguard::addPeer()` to automate tunnel setup. Configurations are typically validated against WireGuard’s schema before application.
- Will this work with Laravel’s service container and dependency injection?
- The bundle assumes Symfony’s container, but you can integrate it with Laravel by wrapping its services in a decorator or facade. Bind the bundle’s services in your Laravel ServiceProvider’s `register()` method and resolve them with `app('wireguard')`. For complex dependencies, consider using Laravel’s `bind()` method to map Symfony interfaces to Laravel implementations.
- Are there any Laravel-specific features, like Artisan commands or Blade directives?
- The bundle itself doesn’t include Laravel-specific features, but you can extend it by publishing its assets (via `php artisan vendor:publish --tag=all`) and adding Artisan commands or Blade directives in your own package. Check the published config files for hooks or events you can leverage.
- How do I handle WireGuard configurations in Laravel’s database or storage?
- The bundle doesn’t enforce a storage method, so you can save configurations to Laravel’s database (e.g., using Eloquent models) or files. For database storage, create a migration for WireGuard configs and use Laravel’s query builder to fetch/update them. If the bundle expects Symfony’s Doctrine, replace it with Laravel’s database layer.
- Does this bundle work with Laravel’s event system for peer/key changes?
- Yes, the bundle’s event system is compatible with Laravel. You’ll need to rebind its event listeners to use Laravel’s `Event` facade or extend the bundle’s event classes. For example, listen for `PeerAddedEvent` using Laravel’s `event()` helper or `Listen` trait in your service classes.
- What Laravel versions and PHP versions are supported?
- The bundle targets Symfony 5.x/6.x, which aligns with Laravel 8+ (PHP 7.4+) or Laravel 9+ (PHP 8.0+). Test thoroughly with your Laravel version, as Symfony’s DependencyInjection or ContainerInterface may require polyfills. Check the bundle’s `composer.json` for PHP version constraints.
- Are there alternatives to this bundle for Laravel WireGuard integration?
- For Laravel, consider standalone PHP libraries like `wireguard-php` or `spatie/laravel-wireguard` (if available) for lighter integrations. If you need full bundle features, this package is the closest match, but you may need to adapt it. For CLI-focused tools, use WireGuard’s `wg` command directly via Laravel’s `Process` facade.
- How do I handle WireGuard CLI dependencies (e.g., `wg`, `ip`) in production?
- Ensure the `wg` and `ip` commands are installed on your production servers. Use Laravel’s `Process` facade to execute these commands cross-platform (e.g., `Process::run('wg show')`). Avoid hardcoding paths; let the bundle or your wrapper handle environment-specific CLI locations. Test CLI interactions in a CI pipeline to catch missing dependencies early.