adadgio/rocket-bundle
Symfony bundle providing API endpoint annotations with configurable authentication (Basic or custom provider), plus utilities like Node-RED connectors/loops, CSV import/export, entity hydration from data, and serializer helpers.
Installation:
composer require adadgio/gear-bundle
Register the bundle in config/bundles.php:
return [
// ...
Adadgio\GearBundle\AdadgioGearBundle::class => ['all' => true],
];
Basic API Auth (Basic Auth Example):
Configure in config/packages/adadgio_gear.yaml:
adadgio_gear:
auth:
type: Basic
user: "your_username"
password: "your_password"
First Use Case: Annotate a controller method to secure an endpoint:
use Adadgio\GearBundle\Component\Api\Annotation\ApiAuth;
class MyController extends AbstractController
{
/**
* @ApiAuth()
*/
public function secureEndpoint()
{
return $this->json(['message' => 'Access granted!']);
}
}
Annotation-Based Security:
@ApiAuth() on controller methods to enforce authentication.adadgio_gear:
auth:
provider: "app.service.api_auth_provider"
NodeRed Integration:
config/packages/adadgio_gear.yaml:
adadgio_gear:
nodered:
enabled: true
url: "http://nodered.example.com"
token: "your_token"
Adadgio\GearBundle\Component\NodeRed\FlowRunner service.CSV Handling:
use Adadgio\GearBundle\Component\Csv\CsvExporter;
$exporter = new CsvExporter();
$exporter->export($data, 'output.csv');
use Adadgio\GearBundle\Component\Csv\CsvReader;
$reader = new CsvReader();
$data = $reader->read('input.csv');
Entity Hydration:
use Adadgio\GearBundle\Component\Entity\Hydrator;
$hydrator = new Hydrator();
$entity = $hydrator->hydrate($arrayData, NewEntity::class);
Serializer:
use Adadgio\GearBundle\Component\Serializer\Serializer;
$serializer = new Serializer();
$json = $serializer->serialize($object);
$object = $serializer->deserialize($json, Object::class);
Deprecation Warning:
security.yaml).league/csv for CSV.symfony/serializer.NodeRed Integration:
HttpClient for better error handling:
$client = $this->get('http_client');
$response = $client->request('POST', 'http://nodered.example.com/flow', [
'headers' => ['Authorization' => 'Bearer your_token']
]);
Auth Configuration:
config. Use environment variables or Symfony’s parameter_bag for secrets:
adadgio_gear:
auth:
user: "%env(API_USER)%"
password: "%env(API_PASSWORD)%"
CSV Handling:
Entity Hydration:
if (!array_key_exists('required_field', $data)) {
throw new \InvalidArgumentException('Missing required field.');
}
Annotations Not Working:
php bin/console cache:clear
debug:container for the api_auth_listener.NodeRed Failures:
try-catch blocks:
try {
$flowRunner->run('flow_name');
} catch (\Exception $e) {
$this->addFlash('error', $e->getMessage());
}
Custom Auth Providers:
Adadgio\GearBundle\Component\Api\Authenticator\AuthProviderInterface:
class CustomAuthProvider implements AuthProviderInterface
{
public function authenticate(Request $request): bool
{
// Custom logic (e.g., JWT validation)
return true;
}
}
config:
adadgio_gear:
auth:
provider: "app.service.custom_auth_provider"
Serializer Extensions:
Adadgio\GearBundle\Component\Serializer\Serializer and injecting custom encoders/normalizers.CSV Customization:
CsvExporter/CsvReader to add headers, custom delimiters, or validation:
class CustomCsvExporter extends CsvExporter
{
protected function configureWriter(WriterInterface $writer)
{
$writer->setDelimiter(';');
}
}
How can I help you explore Laravel packages today?