Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP Composer Autoload Issue

  • 19-05-2015 9:42am
    #1
    Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭


    Hi all, maybe I'm being silly and either not doing something correct or I'm just doing it all wrong, I've introduced composer into an existing project and it's downloading and creating the vendor directory fine and all the packages are available via their namespaces etc.

    Now I've tried to add my existing classes to the composer autoload option but can't seem to get them to load.

    All class files in the 'classes' directory are named '{classname}.php', so for example a class called 'Login' would have a file name of 'Login.php' in the classes directory.

    Directory structure:
    index.php
       media/
       site/
           classes/
               Login.php
           vendor/
           composer.json
    

    Composer Autoload Section:
    "autoload": {
       "psr-0": {
           "site\\": "classes/"
       }
    }
    

    Any help is greatly appreciated?!


Comments

  • Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭Ziycon


    Got it to work eventually.

    Changed this:
    "autoload": {
       "psr-0": {
           "site\\": "classes/"
       }
    }
    

    To:
    "autoload": {
       "psr-0": {
           "": "classes/"
       }
    }
    

    Then ran 'composer dump-autoload' which seems to have solved the issue.


Advertisement