### Complete Configuration Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt A comprehensive example of the Blade Heroicons configuration file, demonstrating all available options including prefix, fallback icon, default classes, and attributes. ```yaml return [ 'prefix' => 'heroicon', 'fallback' => 'question-mark-circle', 'class' => 'w-4 h-4 text-gray-500', 'attributes' => [ 'wire:loading.delay' => 'opacity-50', ], ]; ``` -------------------------------- ### Minimal Configuration Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt An example of a minimal configuration file for Blade Heroicons. This typically includes essential settings like the component prefix and default classes. ```yaml return [ 'prefix' => 'heroicon', 'class' => 'w-4 h-4', ]; ``` -------------------------------- ### Complete Custom Configuration Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md This example demonstrates a fully customized configuration, specifying values for prefix, fallback icon, default CSS class, and custom HTML attributes. ```php 'icon', 'fallback' => 'exclamation-triangle', 'class' => 'w-6 h-6 text-gray-700 flex-shrink-0', 'attributes' => [ 'role' => 'img', 'data-version' => '2.0', ], ]; ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Clone the repository and install development dependencies for package development. ```bash git clone https://github.com/driesvints/blade-heroicons.git cd blade-heroicons composer install ``` -------------------------------- ### Install Production Dependencies Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Install only production dependencies for deployment. ```bash composer install --no-dev ``` -------------------------------- ### Minimal Configuration Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md This configuration sets only the 'prefix' option. All other configuration values will use their default settings. ```php 'heroicon', ]; ``` -------------------------------- ### Production Configuration Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt An example of a production-ready configuration for Blade Heroicons, focusing on performance and essential settings. It might include a fallback icon and specific class definitions. ```yaml return [ 'prefix' => 'heroicon', 'fallback' => 'exclamation-triangle', 'class' => 'w-5 h-5', 'attributes' => [], ]; ``` -------------------------------- ### Install Blade Heroicons Source: https://github.com/driesvints/blade-heroicons/blob/main/README.md Use Composer to install the package. Requires PHP 8.0+ and Laravel 9.0+. ```bash composer require blade-ui-kit/blade-heroicons ``` -------------------------------- ### Verify Package Installation Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md After installation, use this Composer command to confirm that Blade Heroicons has been successfully added to your project. ```bash composer show blade-ui-kit/blade-heroicons ``` -------------------------------- ### Example of Merged Configuration Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md Illustrates the final configuration when a custom prefix is defined in the published config file, while other settings default to package values. ```php return [ 'prefix' => 'icon', // From config/blade-heroicons.php 'fallback' => '', // From package defaults 'class' => '', // From package defaults 'attributes' => [], // From package defaults ] ``` -------------------------------- ### Environment-Based Configuration Setup Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md Shows how to configure Blade Heroicons using environment variables, allowing for different settings per environment. ```php env('ICON_PREFIX', 'heroicon'), 'fallback' => env('ICON_FALLBACK', ''), 'class' => env('ICON_DEFAULT_CLASS', ''), 'attributes' => [ 'width' => env('ICON_WIDTH', null), 'height' => env('ICON_HEIGHT', null), ], ]; ``` ```env ICON_PREFIX=heroicon ICON_DEFAULT_CLASS=w-5 h-5 ICON_WIDTH=24 ICON_HEIGHT=24 ``` -------------------------------- ### Example SVG File Structure (o-bell.svg) Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/07-publishing-and-assets.md Each published SVG file is a complete, valid SVG document. This example shows the structure of the 'o-bell.svg' icon. ```xml ``` -------------------------------- ### Changing Fallback Icon Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md Shows how setting a 'fallback' icon prevents exceptions when an icon is not found, rendering the fallback instead. ```php // Old config: 'fallback' => '' (throws exception) // New config: 'fallback' => 'question-mark-circle' // Old behavior: Exception thrown // New behavior: question-mark-circle renders silently ``` -------------------------------- ### Production Configuration Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md This configuration is optimized for production, using a safe fallback icon and defining the default CSS class via an environment variable. ```php 'heroicon', 'fallback' => 'help-circle', // Safe fallback 'class' => env('ICON_DEFAULT_CLASS', 'w-5 h-5'), 'attributes' => [ 'role' => 'presentation', ], ]; ``` -------------------------------- ### Blade Icons Fluent API Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt This example showcases the fluent API provided by Blade Icons for configuring and rendering icons. It allows for chaining methods to set attributes and classes. ```php Blade::icons()->heroicon('academic-cap', ['class' => 'w-6 h-6', 'style' => 'color: red;']); ``` -------------------------------- ### Example Configuration Merge Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/09-architecture-and-internals.md Illustrates how package default configuration values are merged with user-defined configurations. The final configuration merges user-defined values with any missing keys from the package defaults. ```php ['prefix' => 'heroicon', 'fallback' => '', 'class' => '', 'attributes' => []] ``` ```php ['prefix' => 'icon'] ``` ```php ['prefix' => 'icon', 'fallback' => '', 'class' => '', 'attributes' => []] ``` -------------------------------- ### SVG Post-Processing Middleware Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/09-architecture-and-internals.md Implement custom logic to modify SVG output after compilation. This example shows a basic middleware structure that can be used for post-processing SVG content. ```php class SvgMiddleware { public function handle($request, Closure $next) { $response = $next($request); // Post-process SVG content if needed return $response; } } ``` -------------------------------- ### Tailwind + Heroicons Configuration Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md This configuration is tailored for use with Tailwind CSS, setting a simple 'inline-block' class and an empty attributes array. ```php 'heroicon', 'fallback' => '', 'class' => 'inline-block', 'attributes' => [], ]; ``` -------------------------------- ### Changing Icon Prefix Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md Demonstrates how changing the 'prefix' configuration value affects the usage of icon components in Blade views. ```blade // Old config: 'prefix' => 'heroicon' // Old usage: // New config: 'prefix' => 'icon' // New usage: ``` -------------------------------- ### Install Blade Heroicons via Composer Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt Use Composer to add the Blade Heroicons package to your Laravel project. This is the standard installation method. ```bash composer require "codeat3/blade-heroicons" ``` -------------------------------- ### Accessing Configuration in Service Providers Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md Inject the `Repository` contract to access configuration values in your service providers or application code. This example shows how to retrieve prefix, fallback, class, and attribute settings. ```php use Illuminate\Contracts\Config\Repository; class MyService { public function __construct(Repository $config) { $config = $config->get('blade-heroicons'); $prefix = $config['prefix']; // 'heroicon' $fallback = $config['fallback']; // '' $class = $config['class']; // '' $attributes = $config['attributes']; // [] } } ``` -------------------------------- ### Accessing Configuration in Tests Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md Use the `config()` helper function to access configuration values directly within your tests. This example asserts the default prefix value. ```php $config = config('blade-heroicons'); $this->assertEquals('heroicon', $config['prefix']); ``` -------------------------------- ### Changing Default Classes Example Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/04-configuration-reference.md Illustrates how modifying the 'class' configuration impacts newly rendered icons and those without explicit classes. ```blade // Old config: 'class' => '' // New config: 'class' => 'w-6 h-6 text-gray-500' // Behavior: // // ``` -------------------------------- ### Controller Usage for Icon Service Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/10-testing-and-examples.md Demonstrates how to inject and use the IconService within a Laravel controller to render icons and get asset URLs. ```php // In controller class ReportController extends Controller { public function __construct(private IconService $icons) {} public function show() { return view('report.show', [ 'statusIcon' => $this->icons->statusIcon('success'), 'iconUrl' => $this->icons->assetUrl('document-text'), ]); } } ``` -------------------------------- ### Register Route for View Test Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Example route definition to render a Blade view. This can be used to test if the Heroicon component is rendering correctly in your application. ```php Route::get('/test', function () { return view('test'); }); ``` -------------------------------- ### Navigation Link with Icon Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/00-index.md Create a navigation link that includes an icon for better usability. This example shows a dashboard link. ```blade Dashboard ``` -------------------------------- ### Navigation Bar with Icons Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/05-icon-catalog.md Example of using navigation icons for links in a navigation bar. Ensure icons are sized appropriately using Tailwind CSS classes. ```blade ``` -------------------------------- ### Render Heroicon in Blade View Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Example of how to render a Heroicon component directly in your Blade views. Ensure the icon name and style (outline 'o' or solid 's') are correct. ```blade ``` -------------------------------- ### Use Icons in Blade Templates Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Integrate Heroicons directly into your Blade views using the provided component syntax. This example shows usage within layout and component contexts. ```blade
{{ $slot }}

{{ $message }}

``` -------------------------------- ### Responsive Icon Sizing Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/03-blade-components.md Control icon size responsively using Tailwind CSS classes. This example sets a smaller size for mobile and a larger size for larger screens. ```blade ``` -------------------------------- ### Basic Icon Rendering in Blade Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/02-service-provider-api.md Use these components directly in your Blade views after installation to render icons. Different prefixes denote icon styles (outline, solid, mini, micro) and sizes. ```blade ``` ```blade ``` ```blade ``` ```blade ``` -------------------------------- ### Create Custom View Component for Icons Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/09-architecture-and-internals.md Define reusable icon wrapper components in Blade. This example demonstrates a dynamic component that renders a Heroicon based on provided type and icon name props. ```blade // resources/views/components/alert-icon.blade.php @props(['type' => 'info', 'icon' => 'information-circle']) ``` -------------------------------- ### boot(): void Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/02-service-provider-api.md Called during the service provider boot phase, after all services are registered. This method publishes package assets and configuration when running in the console. Developers typically interact with this method indirectly via Artisan commands. ```APIDOC ## boot(): void ### Description Called during the service provider boot phase, after all services are registered. This method publishes package assets and configuration when running in the console. ### Signature ```php public function boot(): void ``` ### Parameters None ### Return Type `void` ### Behavior 1. Checks if the application is running in console mode (`$this->app->runningInConsole()`) 2. If console: publishes the SVG icon files from `resources/svg` to `public/vendor/blade-heroicons` 3. If console: publishes the configuration file from `config/blade-heroicons.php` to the application's `config/` directory ### Publishing Tags - Tag `blade-heroicons`: Publishes raw SVG files to `public/vendor/blade-heroicons` - Tag `blade-heroicons-config`: Publishes configuration to `config/blade-heroicons.php` ### Example Usage ```php // Developers use artisan commands to publish assets (automatic via boot()) // Publish SVG files to public directory php artisan vendor:publish --tag=blade-heroicons // Publish and force overwrite existing files php artisan vendor:publish --tag=blade-heroicons --force // Publish configuration file php artisan vendor:publish --tag=blade-heroicons-config ``` ``` -------------------------------- ### Boot Blade Heroicons Service Provider Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/09-architecture-and-internals.md This method handles the boot phase of the service provider. If the application is running in the console, it registers paths for publishing SVG assets and configuration files. ```php public function boot(): void { if ($this->app->runningInConsole()) { // Publish SVG assets $this->publishes([ __DIR__.'/../resources/svg' => public_path('vendor/blade-heroicons'), ], 'blade-heroicons'); // Publish configuration $this->publishes([ __DIR__.'/../config/blade-heroicons.php' => $this->app->configPath('blade-heroicons.php'), ], 'blade-heroicons-config'); } } ``` -------------------------------- ### Checkbox with Icon Confirmation Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/05-icon-catalog.md Example of a checkbox that displays a check icon when selected. This provides a visual confirmation of the checked state. ```blade ``` -------------------------------- ### Publish Configuration File Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/README.md Optionally publish the configuration file to customize package settings. This command requires the `php artisan` command. ```bash php artisan vendor:publish --tag=blade-heroicons-config ``` -------------------------------- ### List Solid Icons Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/05-icon-catalog.md Lists the first 20 solid icons from the resources/svg directory. Useful for identifying and previewing solid style icons. ```bash ls resources/svg/ | grep "^s-" | head -20 # List solid icons ``` -------------------------------- ### Run Tests and Linting Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Execute tests and linting checks for the package. ```bash composer test ``` ```bash composer lint ``` -------------------------------- ### Accessing Configuration in Application Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/02-service-provider-api.md Demonstrates how to retrieve the 'blade-heroicons' configuration values from the application's config repository. This is useful for dynamically accessing settings like the icon component prefix. ```php $config = $this->app->make('config')->get('blade-heroicons'); $prefix = $config['prefix'] ?? 'heroicon'; ``` -------------------------------- ### Enable View Caching in Production Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Configure view caching in `config/view.php` and set the expiration in `.env` for production performance. ```php 'cache' => env('VIEW_CACHE_EXPIRATION', 3600), ``` ```env VIEW_CACHE_EXPIRATION=3600 ``` -------------------------------- ### Basic Heroicon Component Usage Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/03-blade-components.md Demonstrates the simplest way to render an outline-style Heroicon component. This is the default way to include an icon. ```blade ``` -------------------------------- ### Document List Display with Document, Photo, and Video Icons Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/05-icon-catalog.md Organize and display different file types in a list, using `x-heroicon-o-document`, `x-heroicon-o-photo`, and `x-heroicon-o-video-camera` to visually distinguish them. ```blade
Report.pdf
photo.jpg
video.mp4
``` -------------------------------- ### Blade Icons View Caching Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt Example of enabling view caching for Blade Icons to improve performance. This is typically configured in the application's configuration files. ```php // Example configuration snippet (actual location may vary) 'cache' => true, ``` -------------------------------- ### Basic Blade Component Usage Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt Demonstrates the basic syntax for using a Blade Heroicon component. The naming convention is . Ensure the correct style and icon name are used. ```blade ``` -------------------------------- ### Blade Heroicons Dependency Chain Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/00-index.md Details the dependency hierarchy for the blade-heroicons package within a Laravel application, starting from the app itself down to the core SVG icon library. ```text Your Laravel App ↓ blade-ui-kit/blade-heroicons (^2.0) ↓ blade-ui-kit/blade-icons (^1.6) ↓ illuminate/support (^9.0|^10.0|^11.0|^12.0|^13.0) ↓ refactoringui/heroicons (1,290+ SVG icons) ``` -------------------------------- ### Publish Assets to Custom Directory Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/07-publishing-and-assets.md After configuring a custom publishing directory in your service provider, run the vendor:publish command to publish the assets to the specified location. ```bash php artisan vendor:publish --tag=blade-heroicons # Files published to: public/icons/heroicons/ ``` -------------------------------- ### List Micro Icons Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/05-icon-catalog.md Lists the first 20 micro icons from the resources/svg directory. This command is helpful for developers looking for the smallest icon sizes. ```bash ls resources/svg/ | grep "^c-" | head -20 # List micro icons ``` -------------------------------- ### Configure Local Project for Path Repository Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/08-installation-and-setup.md Configure your local project's composer.json to use the package from a local path for testing. ```json { "repositories": [ { "type": "path", "url": "/path/to/blade-heroicons" } ], "require": { "blade-ui-kit/blade-heroicons": "@dev" } } ``` -------------------------------- ### Responsive Size Icon in Blade Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/07-publishing-and-assets.md Apply Tailwind CSS classes to the `` tag for responsive sizing. This example sets base size and larger sizes for medium screens and up. ```blade ``` -------------------------------- ### Run Tests with Verbose Output Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/10-testing-and-examples.md Run all tests with detailed output to help diagnose issues. Use this command for more insight into test execution. ```bash composer test -- --verbose ``` -------------------------------- ### Applying SVG Attributes to Blade Components Source: https://github.com/driesvints/blade-heroicons/blob/main/_autodocs/DOCUMENTATION-SUMMARY.txt Illustrates how to pass arbitrary SVG attributes to a Blade Heroicon component. These attributes are directly applied to the root SVG element. For example, 'aria-hidden' for accessibility. ```blade