common-gateway/first-test-bundle
Install the Bundle Run in your Laravel project root:
composer require common-gateway/first-test-bundle:dev-main
(Note: Replace dev-main with a stable version if available.)
Enable the Bundle
Add to config/app.php under providers:
CommonGateway\FirstTestBundle\FirstTestBundle::class,
(If using Symfony Flex, this may auto-register.)
First Use Case: Verify Installation
Create a test route in routes/web.php:
use CommonGateway\FirstTestBundle\Service\ExampleService;
Route::get('/test-bundle', function (ExampleService $service) {
return $service->getExampleMessage(); // Hypothetical method
});
Visit /test-bundle to confirm the bundle’s core functionality works.
Service Integration
ExampleService) into Laravel controllers/services.public function __construct(private ExampleService $exampleService) {}
Configuration Overrides
php artisan vendor:publish --provider="CommonGateway\FirstTestBundle\FirstTestBundle" --tag="config"
config/first-test-bundle.php.Event Listeners
EventServiceProvider:
protected $listen = [
'common-gateway.event.example' => [
'App\Listeners\HandleExampleEvent',
],
];
Asset Integration
app.blade.php:
@vite(['resources/js/first-test-bundle.js'])
$this->app->bind('custom.service', function ($app) {
return new CustomService($app->make(ExampleService::class));
});
php artisan migrate --path=/vendor/common-gateway/first-test-bundle/src/Database/Migrations
Namespace Collisions
CommonGateway\FirstTestBundle) may conflict with your app’s namespace.composer.json:
"autoload": {
"psr-4": {
"App\\": "app/",
"CommonGateway\\FirstTestBundle\\": "vendor/common-gateway/first-test-bundle/src/"
}
}
Then run composer dump-autoload.Missing Documentation
src/Service/ for available classes/methods.tests/ for usage examples (if present).Dev Dependency Lock
:dev-main, which may break across updates.Symfony vs. Laravel Quirks
ArgumentResolver or EventDispatcher.
Fix: Manually bind Symfony services in AppServiceProvider:
$this->app->singleton(Symfony\Component\EventDispatcher\EventDispatcher::class, function () {
return new EventDispatcher();
});
Check for Errors
composer dump-autoload after installation.php artisan cache:clear && php artisan config:clear
Log Bundle Activity
$dispatcher->addListener('common-gateway.event.example', function ($event) {
\Log::debug('Bundle event triggered', $event->toArray());
});
Verify Autoloading
composer show common-gateway/first-test-bundle
Ensure the autoload section in composer.json is correct.Customizing Services
AppServiceProvider:
$this->app->bind(
CommonGateway\FirstTestBundle\Service\ExampleService::class,
CustomExampleService::class
);
Adding Commands
use CommonGateway\FirstTestBundle\Command\ExampleCommand;
class CustomExampleCommand extends ExampleCommand {
protected function execute(InputInterface $input, OutputInterface $output) {
// Extend logic here
parent::execute($input, $output);
}
}
Database Schema
app/Database/Migrations/:
use CommonGateway\FirstTestBundle\Database\Migrations\CreateExampleTable;
class ExtendExampleTable extends CreateExampleTable {
public function up() {
parent::up();
Schema::table('example_table', function ($table) {
$table->string('custom_column')->nullable();
});
}
}
How can I help you explore Laravel packages today?