marcelorodrigo/filament-barcode-scanner-field
# Run all tests
composer test
# Run tests (CI mode - faster, no coverage)
composer test:ci
# Run tests with coverage report
composer test:coverage
# Run a single test file
vendor/bin/pest tests/Unit/BarcodeInputTest.php
# Run tests matching a pattern
vendor/bin/pest --filter="creates a barcode input instance"
# Static analysis with PHPStan (level 4)
composer analyse
# Check code style
composer pint
# Fix code style automatically
composer pint:fix
# Run Rector (automatic refactoring)
composer refactor
# Dry-run Rector to see what would change
composer test:refactor
# Check code style in test mode (CI)
composer test:lint
Marcelorodrigo\FilamentBarcodeScannerFieldsrc/ maps to namespace rootUses Laravel preset with custom rules in pint.json:
{
"preset": "laravel",
"rules": {
"blank_line_before_statement": true,
"concat_space": {"spacing": "one"},
"method_argument_space": true,
"single_trait_insert_per_statement": true,
"types_spaces": {"space": "single"}
}
}
Key formatting rules:
string . ' text' (space around dot)array<string, int> (single space in generics)use statementOrder:
declare(strict_types=1); (if used)namespace declarationuse statements (group by type: PHP built-in, external packages, internal)Example:
<?php
namespace Marcelorodrigo\FilamentBarcodeScannerField\Forms\Components;
use Filament\Forms\Components\TextInput;
use Illuminate\Contracts\Support\Htmlable;
class BarcodeInput extends TextInput
{
// ...
}
static return type for fluent methods that return $this#[\Override] attribute when overriding parent methods?string or string|nullExample:
public function icon(string $icon): static
{
return $this->extraAttributes(['icon' => $icon]);
}
protected function setUp(): void
{
parent::setUp();
// ...
}
StudlyCase (e.g., BarcodeInput, FilamentBarcodeScannerFieldServiceProvider)camelCase (e.g., setUp(), configurePackage())camelCase (e.g., $viewNamespace)Test.php (e.g., BarcodeInputTest.php)Test structure:
describe('Feature Group', function () {
it('describes what the test does', function () {
// Arrange
$component = BarcodeInput::make('barcode');
// Act & Assert
expect($component)->toBeInstanceOf(BarcodeInput::class);
});
});
describe() blocks to group related testsexpect() API for assertionsTestCase from tests/TestCase.phptests/Unit/ and tests/Feature/Configured in rector.php:
src/ and config/ directoriesTextInput)filament-barcode-scanner-field:: namespacestatic)extraAttributes() methodsetUp() for initialization (call parent::setUp() first)Package assets are managed via Filament's Asset Manager:
Automatic CSS Loading:
// In service provider
use Filament\Support\Assets\Css;
use Filament\Support\Facades\FilamentAsset;
public function packageBooted(): void
{
FilamentAsset::register([
Css::make('barcode-scanner-field', __DIR__ . '/../resources/css/barcode-scanner-field.css')
->loadedOnRequest(),
], 'marcelorodrigo/filament-barcode-scanner-field');
}
In Blade templates:
<div x-load-css="[[@js](https://github.com/js)(\Filament\Support\Facades\FilamentAsset::getStyleHref('barcode-scanner-field', 'marcelorodrigo/filament-barcode-scanner-field'))]">
Publishable Assets:
Enable via $package->hasAssets() in configurePackage(). Users can customize:
php artisan vendor:publish --tag=filament-barcode-scanner-field-assets
CSS Conventions:
fi- prefix for custom CSS classes (e.g., .fi-barcode-scanner-icon)resources/css/src/
├── Forms/Components/ # Form components
├── Facades/ # Laravel facades
├── Testing/ # Testing traits
├── *.php # Service providers, main class
resources/
├── css/ # CSS assets (auto-loaded via Filament Asset Manager)
├── lang/ # Translation files
└── views/ # Blade templates
tests/
├── Unit/ # Unit tests (isolated components)
├── Feature/ # Feature/integration tests
├── Livewire/ # Test Livewire components
├── resources/views/ # Test views
├── TestCase.php # Base test case
└── Pest.php # Pest configuration
resources/views/components/x-load-js for loading external JavaScript (Alpine.js pattern)x-load-css for loading package CSS via Filament Asset Managerstatic::$viewNamespace (e.g., filament-barcode-scanner-field::components.barcode-input)How can I help you explore Laravel packages today?