I am developing a package based on the an api for admin panel I did using laravel and Service Archicture. I hace included Services folder in the src folder. I now want to change it into a package however I am getting error.
{
"message": "Target class [App\\Services\\UserService] does not exist.",
"exception": "Illuminate\\Contracts\\Container\\BindingResolutionException",
"file": "D:\\microvision\\projects\\_test\\packages\\test-project-1\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php",
"line": 946,
I am developing a package based on the an api for admin panel I did using laravel and Service Archicture. I hace included Services folder in the src folder. I now want to change it into a package however I am getting error.
{
"message": "Target class [App\\Services\\UserService] does not exist.",
"exception": "Illuminate\\Contracts\\Container\\BindingResolutionException",
"file": "D:\\microvision\\projects\\_test\\packages\\test-project-1\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php",
"line": 946,
Share
Improve this question
edited Feb 4 at 5:22
James Z
12.3k10 gold badges27 silver badges47 bronze badges
asked Feb 3 at 18:29
Sospeter Mong'areSospeter Mong'are
1211 silver badge11 bronze badges
2
|
1 Answer
Reset to default 0You're likely referencing the wrong namespace. In your package, update your service bindings from App\Services\UserService
to the correct package namespace (e.g., Vendor\Package\Services\UserService
), adjust your composer.json autoload settings accordingly, and run composer dump-autoload
.
App
as your root namespace if you are developing a package since that will conflict with the root namespaces of most people that would want to use the package – apokryfos Commented Feb 3 at 23:28