Open delfinn55 opened 1 year ago
@delfinn55 Thank you for reporting this. I was able to reproduce it, so I am on my way to fix it!
Will keep this open until it is fixed. Thanks again!
Not sure this is a bug, or a feature request...
The value in the config file for crud_controllers
is designed to only let DevTools know where it should look for existing Crud Controllers, as stated in the comment:
// Where should DevTools look for existing CrudControllers?
'crud_controllers' => [
app_path('Http/Controllers/Admin'),
]
That means the paths set there are not used (nor intended) to create new Crud Controllers!
However... If we want to let users also set the paths for new controllers (which is reasonable), we will need to work both on DevTools as well as Generators.
DevTools
We can add a comment on the config file to indicate that, from all values in the array crud_controllers
, the first will be use to create new ones.
// Where should DevTools look for existing CrudControllers?
// Attention: The first value will be used to create new Controllers
'crud_controllers' => [
app_path('Http/Controllers'),
app_path('Http/Controllers/Admin'),
],
Generators
After adjusting the code in DevTools so that now it uses the first value in the array crud_controllers
(I did that part), we will need to let Generators know that we want another path, since it uses a default hard-coded value.
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Http\Controllers\Admin';
}
@tabacitu who can/should take/continue over this one?
Hmm thanks for the investigation and explanation @maurohmartinez ! Sounds to me like this is a feature request then - “choose where CrudControllers are generated”.
It’s a perfectly reasonable feature request, I agree we should do it. But let’s not dedicate resources to this right now - we have tons to do about the v6 launch. Let’s postpone this until May-June 2023, after we have v6. It’s a non-breaking change after all.
@delfinn55 thanks for submitting this, I totally agree - we’ll prioritize and do this on the timeline above.
Cheers!
Bug report
What I did
What I expected to happen
I expected NewCrudController.php to be created in the folder 'Http/Controllers', but the folder was 'Http/Controllers/Admin'.
What I've already tried to fix it
I searched the backpack config files and traces of presence 'Admin' in 'vendor/backpack' folder.
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:PHP VERSION:
PHP 8.2.4 (cli) (built: Apr 3 2023 12:58:01) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.4, Copyright (c) Zend Technologies with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans with Zend OPcache v8.2.4, Copyright (c), by Zend Technologies
LARAVEL VERSION:
v9.52.5@e14d28c0f9403630d13f308bb43f3d3cb73d6d67
BACKPACK PACKAGE VERSIONS:
backpack/crud: 5.5.7 backpack/devtools: 1.3.5 backpack/generators: 3.3.16 backpack/langfilemanager: 4.1.0 backpack/logmanager: v4.0.10 backpack/permissionmanager: 6.0.16 backpack/pro: 1.6.4 backpack/settings: 3.0.16
Operating System and Server Setup
I encountered the problem above on my [Mac OS] machine, and my web server is set up using [nginx + MySQL5.7 + php8.2.4].