最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Target class [App\Services\UserService] does not exist in laravel package - Stack Overflow

programmeradmin0浏览0评论

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
  • Ensure App\Services\UserService exists and has the right namespace – Emeka Mbah Commented Feb 3 at 22:38
  • Don't use 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
Add a comment  | 

1 Answer 1

Reset to default 0

You'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.

发布评论

评论列表(0)

  1. 暂无评论