Using Vendor Libraries Best Practices - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Using Vendor Libraries Best Practices (/showthread.php?tid=85868) |
Using Vendor Libraries Best Practices - DDCS - 12-14-2022 I have tried searching for an existing answer but I have not found one. Feel free to point me to any previously answers I missed. Also, if this belongs somewhere else please let me know and I will move it. I am trying to use packages located in the "vendor" folder; at the same level as the "app" folder in the directory tree. So far as I can tell these should be autoloaded when the program starts but I cannot access them. My controller (LoadController) is designed to send data from a web app into Hubspot CRM; at the head I am using the following: Code: <?php namespace App\Controllers; Quote:"Class 'App\Controllers\HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput' not found" Is there something I am missing, or am I just not understanding how to use these packages? I feel as if there is something fundamental I am missing, or the site itself is mis-configured. Mostly I think I am just doing something dumb. RE: Using Vendor Libraries Best Practices - kenjis - 12-16-2022 You just don't understand PHP's namespaces. Not $simplePublicObjectInput = new HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput([ But $simplePublicObjectInput = new \HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput([ You wrote `HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput` in the namespace `App\Controllers`. So it is interpreted as App\Controllers\HubSpot\Client\Crm\Tickets\Model\SimplePublicObjectInput. RE: Using Vendor Libraries Best Practices - DDCS - 12-17-2022 I have been working with PHP namespaces since they were introduced in 2009; pretty sure I have a handle on them. Thanks for the extra set of eyes though, I completely missed the leading backslash. As I said, just a dumb mistake on my part. |