Bug 203304

Summary: [patch] lang/php56: change default include_path for better matching FreeBSD packages
Product: Ports & Packages Reporter: Torsten Zühlsdorff <ports>
Component: Individual Port(s)Assignee: Alex Dupre <ale>
Status: Closed Not Accepted    
Severity: Affects Only Me CC: gasol.wu, miwi, ports
Priority: --- Keywords: patch
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
path to modify include_path none

Description Torsten Zühlsdorff 2015-09-24 09:01:55 UTC
Created attachment 161323 [details]
path to modify include_path

Hello,

the ports-tree provide a big number of php-scripts to use. mail/phpmailer, www/dddbl, www/pear-twig and many many more.

PHP brings a configuration "include_path", which is used, when including files in PHP code. It defaults to ".:/usr/local/share/pear". This means, that PHP looks first in the current folder "." to include the file. If the file is not there, it will look secondly into /usr/local/share/pear.

Many PHP libraries are installed to /usr/local/share. If a user wants to use the installed libs from the ports-tree, he has to modify the include_path in its scripts (every time).

This is a minor annoyance, which is changed by the provided patch. The patch modify the php.ini files to add the /usr/local/share path to the include_path. A default PHP installation will be able to use libs installed with pkg or ports-tree by default.

The patch is just for PHP 5.6 because i don't know if you agree with my option. If you agree, i will wrote the patch for the other PHP versions in the ports-tree.

Greetings,
Torsten
Comment 1 Gasol Wu 2015-09-24 10:56:20 UTC
-1
Comment 2 Torsten Zühlsdorff 2015-09-24 10:57:24 UTC
(In reply to Gasol Wu from comment #1)
A simple "-1" is not very helpful. ;) Can you explain your opinion? 

Thanks,
Torsten
Comment 3 Gasol Wu 2015-09-25 10:24:24 UTC
I'm not native speaker, Here is explanation of my concern:

There is no reason to put /usr/local/share to include_path, Because not all stuff in /usr/local/share is php-related, The another reason is, It sounds like you want to put application-specific configuration in system configuration (php.ini), It will affects all of application running on the same machine.

It's not recommend to use include_path anyway, Nowadays, Most of PHP libraries use PSR-4 and PSR-1 (is deprecated) standard to load classes automatically. The autoload mechanism is the way better and faster than include_path lookup.

Just my two cents.

Best regards,
Gasol.
Comment 4 Torsten Zühlsdorff 2015-09-25 10:42:07 UTC
(In reply to Gasol Wu from comment #3)

I'm also not a native speaker. This is no problem - i think i've got your point. Thank you very much for your explanation! :)

Yes, its right, that not all stuff under /usr/local/share is PHP related. But in my opinion this isn't really an argument against the patch. It's an argument against the structure. Because sometimes there is an /usr/local/share/php. An for PEAR libraries there is /usr/local/share/pear.

Affection of all installed/running programs is a valid point. But i do not see any incompatibilities. I've just adding a third include_path. If an application relies at this directive it still will work. (Maybe i have to change the order to be sure). If it relies not, it will still work. If it redefines it, it will still work.

I do not intend to put applications specific code into system-configuration. My patch addresses the inconsistency of allowing the installation of PHP libraries but not being able to use them without the modification of the application.

Autoloading is not affected by this patch. There are many PHP programs which do not use Autoloading. It may be the actual standard, but it is not an enforced standard. In Reality it is just another possibility.
Comment 5 Torsten Zühlsdorff 2015-09-25 14:35:33 UTC
As an addition: when you install some libraries, like mail/phpmailer for example, you get the advise to change the php.ini file:


Message for phpmailer-5.2.7:
You need to adjust php's include_path to contain `/usr/local/share/phpmailer'!
For example, insert
        include_path = ".:/usr/local/share/phpmailer"
into `/usr/local/etc/php.ini'.

This would be obsolete with my patch.

Greetings,
Torsten
Comment 6 Torsten Zühlsdorff 2016-03-08 16:20:20 UTC
Alex,

are you planning to respond to this?

I also add miwi@ in cc, because he maintains php70, where this suggestion could also have some relevance.

Greetings,
Torsten
Comment 7 Alex Dupre freebsd_committer freebsd_triage 2016-03-08 19:45:34 UTC
I don't agree with this change, if you want to add /usr/local/share to include_path you can already do by modifying your php.ini, this is not the right path.
Comment 8 Torsten Zühlsdorff 2016-03-09 08:38:55 UTC
(In reply to Alex Dupre from comment #7)

> if you want to add /usr/local/share to include_path you can 
> already do by modifying your php.ini, this is not the right path.

This is exactly what the patch does...
Comment 9 Alex Dupre freebsd_committer freebsd_triage 2016-03-09 09:09:25 UTC
With the difference that you are manually overriding a setting with an insecure value instead of forcing all FreeBSD users to have it as default.
Comment 10 Torsten Zühlsdorff 2016-03-09 10:52:19 UTC
(In reply to Alex Dupre from comment #9)

> With the difference that you are manually overriding a setting with an 
> insecure value instead of forcing all FreeBSD users to have it as default.

Okay, how to set it for all FreeBSD users as default?