Welcome Guest, Not a member yet? Register   Sign In
Composer not loading from php include dir
#1

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.
Reply
#2

PHP 5.2.4.
See http://www.codeigniter.com/user_guide/ge...ments.html
Reply
#3

(This post was last modified: 06-15-2015, 08:08 PM by gdhnz.)

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.
Reply
#4

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
Reply
#5

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.
Reply
#6

(This post was last modified: 06-16-2015, 01:04 PM by gdhnz.)

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

(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.
Reply
#8

(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/ge...oader.html
Reply
#9

(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/ge...oader.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.
Reply
#10

(This post was last modified: 06-18-2015, 08:28 PM by gdhnz.)

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB