F
Filamentβ€’13mo ago
Gunnolfson

Unable to detect application namespace.

Hi I'm working on a new project. We set up an architecture based on the Laravel Beyond Crud ebook written by Spatie. We then splitted our code into Application and Domain folders. To do this, we edited the autoload section and the bootstrap.php file:
"autoload": {
"psr-4": {
"App\\": "src/Application/",
"Domain\\": "src/Domain/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"autoload": {
"psr-4": {
"App\\": "src/Application/",
"Domain\\": "src/Domain/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
$app = new Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
$app->useAppPath('src/Application');
$app = new Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
$app->useAppPath('src/Application');
I also changed some configuration inside filament.php to point out the new folders:
return [
'pages' => [
'namespace' => 'Domain\\Admin\\Pages',
'path' => app_path('../Domain/Admin/Pages'),
'register' => [
Pages\Dashboard::class,
],
],
'resources' => [
'namespace' => 'Domain\\Admin\\Resources',
'path' => app_path('../Domain/Admin/Resources'),
'register' => [],
],
'widgets' => [
'namespace' => 'Domain\\Admin\\Widgets',
'path' => app_path('../Domain/Admin/Widgets'),
'register' => [
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
],
],
'livewire' => [
'namespace' => 'Domain\\Admin',
'path' => app_path('../Domain/Admin'),
],
];
return [
'pages' => [
'namespace' => 'Domain\\Admin\\Pages',
'path' => app_path('../Domain/Admin/Pages'),
'register' => [
Pages\Dashboard::class,
],
],
'resources' => [
'namespace' => 'Domain\\Admin\\Resources',
'path' => app_path('../Domain/Admin/Resources'),
'register' => [],
],
'widgets' => [
'namespace' => 'Domain\\Admin\\Widgets',
'path' => app_path('../Domain/Admin/Widgets'),
'register' => [
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
],
],
'livewire' => [
'namespace' => 'Domain\\Admin',
'path' => app_path('../Domain/Admin'),
],
];
The test suite works well and the other pages are also working. Seems only Filament got the issue πŸ€” Any idea how to debug this?
2 Replies
Dennis Koch
Dennis Kochβ€’13mo ago
Did you clear your config? What is the exact issue?
Gunnolfson
Gunnolfsonβ€’13mo ago
Oh my bad, I finally figured it out... Seems writing my problem lead me to the real issue 🀦 I forgot to specify the new namespace in the custom Application class:
class Application extends \Illuminate\Foundation\Application
{
protected $namespace = 'App\\';
}
class Application extends \Illuminate\Foundation\Application
{
protected $namespace = 'App\\';
}
I let it there so maybe someone will finds it with search πŸ˜… Thanks for your time πŸ™