Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 523 Vote(s) - 3.39 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Composer doesn't autoload packages

#1
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 {}
Reply

#2
First of all, it's often better to use `psr-0` or `psr-4` autoloading config. With the classmap, you have to redump the autoloader each time you add a new class or rename one.

You always need to include the Composer autoloader by using `require 'vendor/autoload.php';`. The best place to add such require statement is in your front controller file.
Reply

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



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through