Welcome Guest, Not a member yet? Register   Sign In
how to use composer when application and system directory are not in webroot?
#3

(This post was last modified: 11-10-2019, 09:29 AM by sneakyimp.)

(11-08-2019, 02:03 PM)daveĀ friend Wrote: Assuming you want vendor/ at the same level as application/ then, using the example code below, adjusting for some other file structure is automatic as long as vendor/ and application/ retain the same relationship in the file hierarchy
Might this introduce any problems with composer? I'd point out that any composer changes, such as installing the packages I described in my OP, would be making adjustments to the composer.json file that exists as part of the basic CodeIgniter install. I worry that this might introduce problems.

(11-08-2019, 02:03 PM)dave friend Wrote:
PHP Code:
$config['composer_autoload'] = str_replace('application/''vendor/'APPATH); 
I would point out that this would be problematic if my project had "application/" in its path already. E.g., if my project were called "my-application" instead of "project" and was installed at /var/www/my-application/.

(11-08-2019, 02:03 PM)dave friend Wrote:
PHP Code:
$config['composer_autoload'] = APPATH 'vendor/'
That path, if I'm not mistaken, is where CodeIgniter assumes your autoload file is by default. You could just set it to TRUE and CodeIgniter would look in that spot for the autoload file. This is partly what prompted my question in the first place. If CodeIgniter by default looks for the autoload file at application/vendor/autoload.php, perhaps there is some compelling reason for that location to be used?

Also, I prefer *not* to use the autoload feature myself because the vast majority of controller methods I've defined have no need for the libraries I'm installing using composer. There's no point in loading composer's autoloader for the vast majority of pages on my site. For this reason, I prefer to only load the autoloader manually when the libraries are needed like so:
PHP Code:
require_once APPPATH "vendor/autoload.php"
It's still a bit disappointing that I must autoload ALL my composer-installed libraries at once rather than just loading the one I need at a given time. It seems a bit inefficient. I pretty much never need to use sendgrid and google vision SDKs at the same time.
Reply


Messages In This Thread
RE: how to use composer when application and system directory are not in webroot? - by sneakyimp - 11-10-2019, 09:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB