{"id":15016956,"url":"https://github.com/joserick/laravel-livewire-discover","last_synced_at":"2025-09-01T07:39:14.967Z","repository":{"id":219135768,"uuid":"748270026","full_name":"joserick/laravel-livewire-discover","owner":"joserick","description":"Automatically discover and load/register multiple/different class namespaces for Livewire components.","archived":false,"fork":false,"pushed_at":"2024-11-07T19:16:46.000Z","size":137,"stargazers_count":27,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-01T11:07:25.404Z","etag":null,"topics":["laravel","laravel-package","livewire","livewire-components","livewire-laravel","livewire3","namespace"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joserick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-25T16:20:15.000Z","updated_at":"2025-07-24T17:33:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"51eb0a99-713d-4ffc-9c8b-da0c7835db85","html_url":"https://github.com/joserick/laravel-livewire-discover","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"25c31be446e8282210fed42f4908ce84a7406cde"},"previous_names":["joserick/laravel-livewire-discover"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/joserick/laravel-livewire-discover","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joserick%2Flaravel-livewire-discover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joserick%2Flaravel-livewire-discover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joserick%2Flaravel-livewire-discover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joserick%2Flaravel-livewire-discover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joserick","download_url":"https://codeload.github.com/joserick/laravel-livewire-discover/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joserick%2Flaravel-livewire-discover/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273089628,"owners_count":25043807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-package","livewire","livewire-components","livewire-laravel","livewire3","namespace"],"created_at":"2024-09-24T19:49:36.646Z","updated_at":"2025-09-01T07:39:14.909Z","avatar_url":"https://github.com/joserick.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/joserick"],"categories":[],"sub_categories":[],"readme":"![laravel_livewire_discover.jpg](https://joserick.com/livewire_discover.jpg)\n# Laravel Livewire Discover\n![Packagist Downloads](https://img.shields.io/packagist/dt/joserick/laravel-livewire-discover?color=blue)   ![GitHub License](https://img.shields.io/github/license/joserick/laravel-livewire-discover) ![GitHub Release](https://img.shields.io/github/v/release/joserick/laravel-livewire-discover?color=2da711)\n\u003e Notice: [Migration to v1.0](https://github.com/joserick/laravel-livewire-discover#migration-to-v1) || [I need previous version (v0.3)](https://github.com/joserick/laravel-livewire-discover#i-need-for-v0.3.2)\n\nAutomatically discover and load/register multiple/different class namespaces for Livewire components.\n\n## Installation\n\nYou can add the package via composer:\n``` bash\ncomposer require joserick/laravel-livewire-discover\n```\nAnd then install the package with artisan:\n```bash\nphp artisan livewire-discover:install\n```\n## Enjoying this package? [![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/joserick)\n## Config\nAdd to *LivewireDiscoverServiceProvider.php*\n``` php\npublic function boot(): void\n{\n  // Load multiples namespace for Livewire components.\n  Livewire::discovers([\n    'my-components' =\u003e 'Namespaces\\\\Livewire',\n    'new-components' =\u003e 'User\\\\Repository\\\\Livewire',\n  ]);\n\n  // Or individually\n  Livewire::discover('my-components', 'Namespaces\\\\Livewire');\n  Livewire::discover('new-components', 'User\\\\Repository\\\\Livewire');\n}\n```\nOr if you like, use \"componentNamespace\" function as in [Blade Templates](https://laravel.com/docs/blade#clipText-53)\n``` php\npublic function boot(): void\n{\n  // Load multiples namespace for Livewire components.\n  Livewire::componentNamespace('Namespaces\\\\Livewire', 'my-components');\n  Livewire::componentNamespace('User\\\\Repository\\\\Livewire', 'new-components');\n  // ...\n}\n```\nOr use the config: *'config/livewire-discover.php'*\n``` php\n// Load the namespace to Livewire components.\n'class_namespaces' =\u003e [\n  // 'prefix' =\u003e 'class\\\\namespace',\n  'my-components' =\u003e 'Namespaces\\\\Livewire',\n  'new-components' =\u003e 'User\\\\Repository\\\\Livewire',\n],\n```\n## Use\nCall Livewire Components:\n``` html\n\u003clivewire:my-components.devices /\u003e \u003c!-- Class: Namespace\\Livewire\\Devices; --\u003e\n\u003clivewire:new-components.auth.login /\u003e \u003c!-- Class: User\\Repository\\Livewire\\Auth\\Login; --\u003e\n\u003clivewire:new-components.auth.register-admin /\u003e \u003c!-- Class: User\\Repository\\Livewire\\Auth\\RegisterAdmin; --\u003e\n```\nOr use form Routes:\n``` php\n// Load Livewire Component from Route\nuse Namespaces\\Livewire\\Devices;\nuse User\\Repository\\Livewire\\DevicesTable;\n\nRoute::get('/devices', Devices::class); // resolve name my-components.devices\nRoute::get('/devices_table', DevicesTable::class); // resolve name new-components.devices-table\n```\n\"Obviously\" you need to install the \"layout\" first for the Routes\n```bash\nphp artisan livewire:layout\n```\n## Extra\n### Displays the list of loaded namespaces (prefix, aliases and paths)\nIf you want to check if all the namespaces are loading correctly you can run:\n```bash\nphp artisan livewire-discover:list\n```\nWhich will show you a table with all the information:\n```bash\nLivewire-Discover namespaces list:\n\nPrefix: 'my-components' (Namespaces\\\\Livewire)\nThere is no \"class path\" defined for the config for prefix 'my-components'\nGetting the \"class path\" from the composer autoload file\n+-----------------------+-----------------------------------------------+\n| Alias                 | Paths                                         |\n+-------------------------------------------+---------------------------+\n| my-components.devices | /var/www/html/namespaces/livewire/devices.php |\n+-----------------------+-----------------------------------------------+\n```\n### Create your components quickly\nYou can create the files automatically using the following Artisan command. In the process it will ask you for the prefix to use.\n```bash\nphp artisan livewire-discover:make RegisterAdmin\n# Or\nphp artisan make:livewire-discover RegisterAdmin\n```\nIf you prefer kebab-cased names, you can use them as well:\n```bash\nphp artisan livewire-discover:make register-admin\n```\nYou may use namespace syntax or dot-notation to create your components in sub-directories. For example, the following commands will create a `RegisterAdmin` component in the `Auth` sub-directory:\n```bash\nphp artisan livewire-discover:make Auth\\\\RegisterAdmin\nphp artisan livewire-discover:make auth.register-admin\n```\nAlso if you don't want it to constantly ask you which prefix to select you can pass it directly with the `--prefix` attribute\n### Manually configure the 'classpath' for component creation and listing\nWhen automatically created components through the `artisan livewire-discover:make` this obtains the directory path based on 'Composer Autoload File' If for some reason it is not possible to do this, you can manually configure the path, adding it as the third parameter:\n``` php\nLivewire::discover(\n    'my-components',\n    'Namespaces\\\\Livewire',\n    app_path('/Path/Livewire') // \u003c-- Components directory path\n);\n```\nNow when you create the component it will be created in the path you have specified.\n### Config 'view path' for component creation\nDo you also want it to create the `view` at a specific route? Just add the view route and it will automatically create it, simple as that:\n``` php\nLivewire::discover(\n    'my-components',\n    'Namespaces\\\\Livewire',\n    app_path('/Path/Livewire')\n    resource_path('/views/path/livewire'), \u003c-- Components views path\n);\n```\nRemember that these are examples, you can specify any path within your project and it will create it.\n## Migration to v1\n### Rename Config File\nThe configuration file name has changed from `laravel-livewire-discover.php` to simply `livewire-discover-php`\n### Attributes Reversed\nReplace `Livewire::discover` for `Livewire::componentNamespace` since the attributes in v1 are reversed but the `componentNamespace` function maintains the structure of previous versions.\n``` php\nLivewire::discover('Namespaces\\\\Livewire', 'my-components');\n```\nto\n``` php\nLivewire::componentNamespace('Namespaces\\\\Livewire', 'my-components');\n```\nor in any case to maintain the use of the `discover()` function you can invert the parameters.\n### Dot-Notation\nChange in concatenation of prefixes with class name, previously it was concatenated using the \"-\" notation, now the dot-notation is used, so it must be changed in all calls to Livewire-Discover components\n``` html\n\u003clivewire:components-devices /\u003e\n```\nto\n``` html\n\u003clivewire:components.devices /\u003e\n```\n## I need for v0.3.2\n```\ncomposer require joserick/laravel-livewire-discover:0.3.2\n```\n\n## License\n\nThe GNU Public License (GPLv3). Please see [License File](https://github.com/joserick/laravel-livewire-discover/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoserick%2Flaravel-livewire-discover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoserick%2Flaravel-livewire-discover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoserick%2Flaravel-livewire-discover/lists"}