相关文章推荐
近视的跑步鞋  ·  WSDL validation·  4 月前    · 
鼻子大的肉夹馍  ·  java - Filter order ...·  1 年前    · 
咆哮的生菜  ·  freeswitch websocket ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I hate to add more to the noise of "autoload isn't working!!!!!", but I can't seem to get this problem figured out, and I figured getting some fresh eyes on it would get the problem in a lot less time. Here is my index.php file:

declare(strict_types=1); require_once 'vendor/autoload.php'; require_once 'model/PageNav.php'; use ShinePHP\{Crud, CrudException, EasyHttp, EasyHttpException, HandleData, HandleDataException}; // ALWAYS serve over encrypted channels try { EasyHttp::checkHttps(); } catch (EasyHttpException $ex) { echo $ex; try { // check if it's a GET request, if it is, serve page, if not, do nothing if (EasyHttp::isRequestMethod('GET')) { $Page = new PageNav('Home', 'view/home.php'); $Page->buildPage(); exit; catch (EasyHttpException $ex) { echo $ex;

So obviously I am using a package from composer called ShinePHP (it's one I've made, and I'm still working on the documentation, so I'm just using it for my own projects at the moment, composer just makes package management so easy!)
ANYWAYS...because I'm writing this question, I'm obviously getting the following error:

Fatal error: Uncaught Error: Class 'ShinePHP\EasyHttp' not found in /Applications/XAMPP/xamppfiles/htdocs/KRTY/src/index.php:11 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/KRTY/src/index.php on line 11

Now, I haven't manually touched the composer.json file, so here it is:

"require": { "adammcgurk/shine-php": "~0.0.1" "autoload": { "psr-4": { "ShinePHP\\": "src/"

I'm not getting any errors on requiring the vendor/autoload.php file (and I've tried changing the path to something that doesn't exist like vendor/alkdjfladksf/autoload.php and it throws an error how it should), I'm running PHP version 7.2.7 on XAMPP on Mac OS Mojave. Here is the directory structure, the highlighted index.php file is the one with the code above:

And here is the output of composer dump-autoload -o:

Generating optimized autoload files

And so...to add more to the fire of this question on Stack...How can I get composer to autoload my ShinePHP namespace with the classes as shown in the code?

This dependency does not have any autoloading rules, so Composer does not know where to find ShinePHP\EasyHttp class. You need to add autoloading configuration in composer.json of shine-php package:

"autoload": {
    "psr-4": {
        "ShinePHP\\": "src/"
                So I added that code to my composer file (the full composer.json is edited above), but I'm still getting the same error
– Adam McGurk
                Jan 4, 2019 at 0:31
                Thank you, that was the problem, I added that to my package and I'm all good now. Thanks for the tip @Sammitch, because I did have to bump my version number
– Adam McGurk
                Jan 4, 2019 at 0:46
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.