CodeIgniter Forums
Composer not loading from php include dir - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Composer not loading from php include dir (/showthread.php?tid=62171)



Composer not loading from php include dir - gdhnz - 06-15-2015

Hi,

I've discovered that composer is not loading when my vendor directory is in one my php.ini include_paths.

On line 173 of system/core/CodeIgniter.php there's the following...

PHP Code:
elseif (file_exists($composer_autoload)) 

...but file_exists only looks in the current directory.

Changing it to...

PHP Code:
elseif (stream_resolve_include_path($composer_autoload)) 

...fixes the issue for me. stream_resolve_include_path is available from 5.3.2 and up.

What's the minimum version of php supported?  I don't see a list of minimum requirements as part of the installation instructions.


RE: Composer not loading from php include dir - kenjis - 06-15-2015

PHP 5.2.4.
See http://www.codeigniter.com/user_guide/general/requirements.html


RE: Composer not loading from php include dir - gdhnz - 06-15-2015

Interesting wording using "should". Does that imply it has to be 5.2.4?

Would it be ok to add a pull request like either of the following or are cross-version workarounds frowned upon?

PHP Code:
if ($composer_autoload === TRUE)
{
 ...
}
elseif (
file_exists($composer_autoload) || 
    
(function_exists("stream_resolve_include_path") && stream_resolve_include_path($composer_autoload)))
{
 ...
}
else{
 ...


or 

PHP Code:
if ($composer_autoload === TRUE)
{
...
}
elseif (
file_exists($composer_autoload))
{
...
}
elseif (
function_exists("stream_resolve_include_path") && stream_resolve_include_path($composer_autoload)))
{
 ...
}
else
{
...


PS, where is the requirements page linked from in the docs? Couldn't see it linked from any of the Instalation instruction pages.


RE: Composer not loading from php include dir - kenjis - 06-16-2015

Why do you add vendor directory to include_paths?
I have never done it. I think it is not needed.

About docs, see "Basic Info" before "Installation":
http://www.codeigniter.com/user_guide/#basic-info


RE: Composer not loading from php include dir - gdhnz - 06-16-2015

I work at a University and we do a lot of similar developments for departments, research groups, etc. For us, it's easier to have a single vendor directory in an include path rather than duplicating the same set of packages for each individual development.


RE: Composer not loading from php include dir - gdhnz - 06-16-2015

Can system/core/CodeIgniter.php be overridden by adding a MY_CodeIgniter.php to application/core?


RE: Composer not loading from php include dir - kenjis - 06-16-2015

(06-16-2015, 01:02 PM)gdhnz Wrote: Can system/core/CodeIgniter.php be overridden by adding a MY_CodeIgniter.php to application/core?

No, you can't.


RE: Composer not loading from php include dir - kenjis - 06-16-2015

(06-16-2015, 12:57 PM)gdhnz Wrote: I work at a University and we do a lot of similar developments for departments, research groups, etc. For us, it's easier to have a single vendor directory in an include path rather than duplicating the same set of packages for each individual development.

You can set a custom path to $config['composer_autoload'].
http://www.codeigniter.com/user_guide/general/autoloader.html


RE: Composer not loading from php include dir - gdhnz - 06-16-2015

(06-16-2015, 07:08 PM)kenjis Wrote:
(06-16-2015, 12:57 PM)gdhnz Wrote: I work at a University and we do a lot of similar developments for departments, research groups, etc. For us, it's easier to have a single vendor directory in an include path rather than duplicating the same set of packages for each individual development.

You can set a custom path to $config['composer_autoload'].
http://www.codeigniter.com/user_guide/general/autoloader.html

To use that I'd need to specify a full path as just adding "vendor/autoload.php" fails the file_exists check in CodeIgniter.php.

I've just remembered, I can use a production directory in the config directory to override the differences between development and production environments.


[Solved] Composer not loading from php include dir - gdhnz - 06-18-2015

What I've done is add the following to my config.

PHP Code:
$config['composer_autoload'] = stream_resolve_include_path("vendor/autoload.php"); 

stream_resolve_include_path returns false if not detected or the full path if it is detected.

Should've thought of this in the first place.