Custom php_value not working

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Custom php_value not working

Postby RiRL » 29. May 2010 01:05

I have set a custom php_value in the apache configuration, but when I call ini_get() from php, the value does not appear
Apache vhosts has
<VirtualHost *:80>
ServerName foo
DocumentRoot "c:\xampp\app1"
<Directory "c:\xampp\htdocs\app1">
AllowOverride All
Options All
php_value include_path ".;C:\xampp\php\pear\;C:\xampp\htdocs;C:\xampp\htdocs\app1;C:\xampp\htdocs\pcweb\app1\class"
php_value bar_name "bar_none"
</Directory>
<Directory "c:\xampp\htdocs\app2">
AllowOverride All
Options All
php_value include_path ".;C:\xampp\php\pear\;C:\xampp\htdocs;C:\xampp\htdocs\app2;C:\xampp\htdocs\app2\class"
php_value bar_name "ou_et_le_bar_jon"
</Directory>
</VirtualHost>

I am expecting, the bar_name to have the corresponding value....in php code, as follows:
<?php
echo nl2br("bar_name has value ini_get("bar_name"). \n");
?>
show either bar_name (directory context for app1) or ou_et_le_bar_jon (directory context for app2).

It prints
bar_name has value .

(meaning the php_value is not be dealt with properly or I have not done it right).
I can use ini_get("include_path") to get the include path, however.

Any suggestions? :?:
RiRL
 
Posts: 7
Joined: 17. December 2009 01:40

Re: Custom php_value not working

Postby JonB » 29. May 2010 03:40

just a question:

are we talking about a script that 'should be common' to both of those values?

or are we talking about two scripts that each run inside their respective vhost?

:?:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Custom php_value not working

Postby RiRL » 01. June 2010 21:53

Thanks Jon,
I am not sure I understand your question, but this I'll try and respond as best I can.

I am trying to be able to obtain an unique value for the bar_name 'property' depending on the respective vhost.
So if the URL is http://foo/app1, then I would like to have ini_get("bar_name") return "bar_none"
So if the URL is http://foo/app2, then I would like to have ini_get("bar_name") return "ou_et_le_bar_jon".

What this will allow me to do is "adapt" the functionality or branding (icons or things) based on the invocation context.
This is going to be used to perform a lookup in some external source. I just need to be able to the get the key value that
varies (somehow) by context.


An alternative solution is too key-off the URL, something like the following:

Given http://foo/app1 index off app1
Given http://foo/app2 index off app2

So I could also use a function like:

function get_app_name($url) {
// input url: => http://foo/app1
// output app: => app1
// HOW? to be determined? Without assuming anything about the form of the URL...
return($app);
}
Not quite sure how to do it. This latter one is probably better since I would not have to mess with the vhosts (for this functionality anyway).
RiRL
 
Posts: 7
Joined: 17. December 2009 01:40

Re: Custom php_value not working

Postby JonB » 01. June 2010 23:32

Ok
-
You DO realize that VirtualHosts don't 'see' each other, right? They are two separate processes, and have no shared namespace. The fact that they may indeed be in the same domain is pure co-incidence. ISP's use them to carve up servers into neat little chunks, right? (IIS has a similar construct) You would't want your neighbor's processes peering into your memory space?

That is NOT what is shown here:

So if the URL is http://foo/app1, then I would like to have ini_get("bar_name") return "bar_none"
So if the URL is http://foo/app2, then I would like to have ini_get("bar_name") return "ou_et_le_bar_jon".

presumably 'foo' defines the host, and because /app1 and /app2 are to the right of 'foo', they represent elements of 'foo' -- i.e. they can't be in different vhosts. The presumption is that 'foo' has the landing page or governs the applications.

I have done my best to explain a tricky concept, I hope this is clearer. :shock:

Good Luck

:)

There are ways on the client side to maneuver across domains. typically with AJAX.
found one:http://www.phpfour.com/blog/2008/03/cross-domain-ajax-using-php/

Cross-domain scripting in NOT a 'best practise'.
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Custom php_value not working

Postby RiRL » 28. September 2010 06:36

This doesn't have anything to do with something as exotic that.

What I want to do is to provide a value that gets passed thru an invocation content by PHP itself, so I can pick it up
in some PHP code, and load resources from a property file.

If you are at all familiar with OO frameworks and inversion of control, it may help understand what I was trying
to do. I was just trying to provide a context for performing dependency injection of PHP code and resources for factory like objects
(and other things) kept in XML and various other formats. I wanted to be able to define an IOC container and use it in PHP.

I never could get this work using the PHP values mechanism. I ended up looking at the URL and adding logic to parse out the "application name"
from it (this took me about 2 days to figure out) on the main PHP page. I then use this to load properties
from the appropriate section of an external PHP ini file.

http://localhost/foo/index.php => by the above logic produces (foo) which is this used to read in a section of properties (some of which
contain XML documents for declaring and binding objects and methods and data) into my application framework. This property file is located outside
the HTDOCS directory (c:\xampp\ioc).

Thanks for the response, however.
RiRL
 
Posts: 7
Joined: 17. December 2009 01:40

Re: Custom php_value not working

Postby Nobbie » 28. September 2010 10:10

What is your question now? Where is your problem?
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 117 guests

cron