Installation Add the package via Composer:
composer require thrace/component-bundle
Register the bundle in config/app.php under providers:
Thrace\ComponentBundle\ThraceComponentBundle::class,
First Use Case
Check the src/Resources/views/ directory for available Blade components. For example, if the bundle includes a Card component, use it in a Blade template:
@component('thrace::card', ['title' => 'Sample Card'])
<p>This is a sample card component.</p>
@endcomponent
Configuration
Review config/thrace.php (if provided) or check the bundle’s service provider for default settings. Override defaults in config/app.php or a custom config file.
Component Integration
@component('thrace::component-name') syntax for reusable UI elements.@component('thrace::alert', ['type' => 'success', 'message' => 'Operation completed'])
@endcomponent
@component('thrace::container')
<div>Slot content here</div>
@endcomponent
Service Integration
Thrace\ComponentBundle\Services\ExampleService), bind them in the service container:
$this->app->bind('thrace.example', function ($app) {
return new \Thrace\ComponentBundle\Services\ExampleService();
});
public function __construct(private ExampleService $exampleService) {}
Asset Management
php artisan vendor:publish --provider="Thrace\ComponentBundle\ThraceComponentBundle" --tag=public
@vite(['resources/css/thrace.css', 'resources/js/thrace.js'])
Configuration Overrides
php artisan vendor:publish --provider="Thrace\ComponentBundle\ThraceComponentBundle" --tag=config
config/thrace.php:
'default_theme' => 'dark',
thrace:: to avoid conflicts (e.g., @component('thrace::button')).@includeIf for optional components:
@includeIf(config('thrace.show_footer'), 'thrace::footer')
$this->app->instance(ExampleService::class, Mockery::mock(ExampleService::class));
Under Development
Component Discovery
View::composer('*', function ($view) {
if (str_contains($view->getName(), 'thrace::')) {
// Pre-process component data
}
});
Asset Conflicts
public/vendor/thrace/ after publishing.Configuration Quirks
readme maturity). Assume hardcoded defaults or check the provider.Dependency Hell
vendor/thrace/component-bundle/src/Resources/views/. Use:
find vendor/thrace/component-bundle -name "*.blade.php"
php artisan package:discover
APP_DEBUG=true) and check Laravel logs (storage/logs/laravel.log) for missing views or syntax issues.Custom Components
Extend existing components by copying them to resources/views/vendor/thrace/ and modifying:
@component('thrace::card')
@slot('header')
Custom Header
@endslot
@endcomponent
Service Decorators Decorate bundle services for custom logic:
$this->app->bind(
ExampleService::class,
function ($app) {
return new CustomExampleService($app->make(ExampleService::class));
}
);
Event Listeners Listen for bundle events (if documented) to hook into workflows:
Event::listen(
\Thrace\ComponentBundle\Events\ComponentRendered::class,
function ($event) {
// Log or modify component output
}
);
Testing
Use Thrace\ComponentBundle\Tests\* as a reference for writing tests. Isolate bundle dependencies with:
$this->partialMock(ExampleService::class, function ($mock) {
$mock->shouldReceive('doSomething')->andReturn('mocked');
});
How can I help you explore Laravel packages today?