PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 24, 2022

[FIXED] Composer doesn't autoload packages

 January 24, 2022     autoload, composer-php, frameworks, php     No comments   

Issue

I'm currently developing a framework but I couldn't figure out how am I going to set autoloading. First I created a package with sample class and composer.json. I've autoloaded that sample class by:

"autoload": {
    "classmap": [
      "libs/"
    ]
}

I've checked /vendor/mypackage/vendor/composer/autoload_classmap.php and confirmed that package's autoloader is working fine. But the problem is I can't reach that package's class from main app unless I directly include that package's autoload.php.

UPDATE

/vendor/foo/mypackage/composer.json

"autoload": {
  "psr-4": {
     "Http\\": "libs/"
   }
}

/vendor/foo/mypackage/libs/Request.php

namespace Http;
class Request {}

Solution

Solved it by myself. I just had to reinstall package whenever I change pacakge's composer.json.



Answered By - İbrahim Duran
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing