{"id":22,"date":"2015-08-27T22:58:51","date_gmt":"2015-08-27T22:58:51","guid":{"rendered":"http:\/\/www.morsello.com\/?p=22"},"modified":"2015-08-27T22:58:51","modified_gmt":"2015-08-27T22:58:51","slug":"appending-php-paths","status":"publish","type":"post","link":"https:\/\/www.morsello.com\/index.php\/2015\/08\/27\/appending-php-paths\/","title":{"rendered":"Appending PHP Paths"},"content":{"rendered":"<div class=\"field field-name-body field-type-text-with-summary field-label-hidden\">\n<div class=\"field-items\">\n<div class=\"field-item even\">\n<p>Mr. Google recommends three different methods for appending additional directories to the PHP include_path:<\/p>\n<p>1. Modify php.ini to set the include path to the desired settings<\/p>\n<p>2. Use .htaccess to do the same<\/p>\n<p>3. Set the path from within code with set_include_path()<\/p>\n<p>All of these, to me, suffer from serious problems. \u00a0What I want, as for any time I&#8217;d like to include additional functionality via code and libraries, is for those libraries to be available globally, and to be set at the meta-level of the code. \u00a0That is, the environment should determine where libraries are stored, and the code should know nothing about it. \u00a0While using set_include_path() within code isn&#8217;t objectionable, there must still be a mechanism for the code to determine what the path should be. \u00a0The code shouldn&#8217;t know or care, for example, where it is stored, let alone where the libraries it relies on are stored.<\/p>\n<p>The ostensibly correct answer is to set the path in php.ini. \u00a0But because this is a setting and not a command, there&#8217;s no way to include the existing default elements of the path in addition to the libaries you&#8217;d like to include. \u00a0You could of course determine what the default values are (which are hard-coded into the compiled PHP executable) and add that to your setting, but hard-coding anything means that changes to later versions of software have now been overridden in a non-obvious way.<\/p>\n<p>My solution of the day is to create a symbolic link in one of the default included directories that refers to a folder with the libraries I want. \u00a0Because this link requires a name, there&#8217;s the additional benefit that including any of my own functionality is obvious from the include line:<\/p>\n<p>require_once(&#8216;my_libraries\/my_project.php&#8217;);<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"field field-name-field-tags field-type-taxonomy-term-reference field-label-above\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Mr. Google recommends three different methods for appending additional directories to the PHP include_path: 1. Modify php.ini to set the include path to the desired settings 2. Use .htaccess to do the same 3. Set the path from within code with set_include_path() All of these, to me, suffer from serious problems. \u00a0What I want, as&hellip;<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/www.morsello.com\/index.php\/2015\/08\/27\/appending-php-paths\/\" title=\"Continue reading &lsquo;Appending PHP Paths&rsquo;\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/posts\/22"}],"collection":[{"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":1,"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":23,"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions\/23"}],"wp:attachment":[{"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.morsello.com\/index.php\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}