Re: Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Tim Streater
On 04 Jan 2012 at 21:59, Robert Williams  wrote: 

> On 1/4/12 14:34, "Tim Streater"  wrote:
>
>> As I hinted in my previous mail, client and server side of my app are
>> always on the user's machine. When the user starts the app, I create an
>> apache config file on the fly and run an instance of apache just for the
>> user. So I'm not messing with the standard OS X Web Sharing. For the same
>> reason, I don't want to start modifying or creating a php.ini file.
>
> In that case, you might consider setting it via the Apache config file
> that you're creating, which you can do with something like:
>
>php_value date.timezone 'America/Phoenix'

OK.

> That'll have the same effect (and benefits) as setting it via php.ini.
>
>>> Hmm, just looked more carefully at the docs. I see I'm going to have to
>>> add a prefs setting so the user can tell my app what timezone they are
>>> in. I find it odd that the OS can't provide this information.
>
> Well, it typically can, or at least can make a guess at it. The problem is
> that it's not something you can rely on across different OSes, as some
> handle it differently, or less reliably, or not at all. Basically, the
> result is non-deterministic. It's for this reason that, as of 5.4, PHP
> won't even ask the OS but will always return UTC (and complain a bit) if
> something else hasn't been set. This way, you at least have a chance of
> consistent results.
>
> If you're only supporting OS X, you can have your script that generates
> the Apache config file retrieve the system time zone, and then use that
> value in the php_value setting. If the script is in PHP, you can do this:
>
>$timeZone = `/usr/sbin/systemsetup -gettimezone`;
>
> Which just calls the systemsetup command line utility (basically, a CLI
> front-end to the settings controlled via System Preferences). Here's what
> that call returns when run on the command line on my system:
>
>H012316WHPV:~ rewilliams$ systemsetup -gettimezone
>Time Zone: America/Phoenix

That is a very helpful hint - thanks. Yes, it's OS X only at the moment as I 
don't have access to or a great interest in the other platforms.


Not sure if this has greatly help the OP though :-)

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Robert Williams
On 1/4/12 14:34, "Tim Streater"  wrote:

>As I hinted in my previous mail, client and server side of my app are
>always on the user's machine. When the user starts the app, I create an
>apache config file on the fly and run an instance of apache just for the
>user. So I'm not messing with the standard OS X Web Sharing. For the same
>reason, I don't want to start modifying or creating a php.ini file.

In that case, you might consider setting it via the Apache config file
that you're creating, which you can do with something like:

php_value date.timezone 'America/Phoenix'

That'll have the same effect (and benefits) as setting it via php.ini.

>>Hmm, just looked more carefully at the docs. I see I'm going to have to
>>add a prefs setting so the user can tell my app what timezone they are
>>in. I find it odd that the OS can't provide this information.

Well, it typically can, or at least can make a guess at it. The problem is
that it's not something you can rely on across different OSes, as some
handle it differently, or less reliably, or not at all. Basically, the
result is non-deterministic. It's for this reason that, as of 5.4, PHP
won't even ask the OS but will always return UTC (and complain a bit) if
something else hasn't been set. This way, you at least have a chance of
consistent results.

If you're only supporting OS X, you can have your script that generates
the Apache config file retrieve the system time zone, and then use that
value in the php_value setting. If the script is in PHP, you can do this:

$timeZone = `/usr/sbin/systemsetup -gettimezone`;


Which just calls the systemsetup command line utility (basically, a CLI
front-end to the settings controlled via System Preferences). Here's what
that call returns when run on the command line on my system:

H012316WHPV:~ rewilliams$ systemsetup -gettimezone
Time Zone: America/Phoenix



Regards,
Bob
--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/







Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Tim Streater
On 04 Jan 2012 at 21:01, Robert Williams  wrote: 

> On 1/4/12 13:33, "Tim Streater"  wrote:
>
> Also, if I remember right, Apple sets up Apache so that each user has
> his/her own config file inside the conf folder. You should make any config
> changes, such as turning on PHP, in there, rather than in the primary
> config file. The latter is subject to being overwritten on OS updates and
> upgrades, while the former is not. Segregating your changes also makes it
> easier to tell exactly what you've changed from the defaults.

This is true.

>> I'm however carefully ensuring that the client and server aspects of my
>> app (which will both run on the user's machine) don't use anything except
>> what comes with the standard OS X distribution, so to fix the date time
>> issue I do:
>>
>>  date_default_timezone_set (@date_default_timezone_get ());
>
> I recommend against this. First of all, in PHP 5.4, this is just going to
> return UTC if you haven't explicitly set the time zone, and that's
> probably not what you want. Plus, the use of @ here leaves a nasty taste
> in the mouth (as it does in most cases).
>
> Instead, I suggest creating a php.ini file and changing this setting there
> by setting it to a specific time zone. For example, in mine, I have this
> line:
>
>date.timezone = 'America/Phoenix'

As I hinted in my previous mail, client and server side of my app are always on 
the user's machine. When the user starts the app, I create an apache config 
file on the fly and run an instance of apache just for the user. So I'm not 
messing with the standard OS X Web Sharing. For the same reason, I don't want 
to start modifying or creating a php.ini file.

> This ensures that PHP is always using the same zone no matter what script
> is running, avoids PHP errors if you forget to make the change in a
> script, avoids you having to modify all your scripts in the first place,
> and lets you easily change the time zone used by your applications to
> whatever you want independently of the server's own time zone (or in 5.4,
> to something other than UTC).

Hmm, just looked more carefully at the docs. I see I'm going to have to add a 
prefs setting so the user can tell my app what timezone they are in. I find it 
odd that the OS can't provide this information.



--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Robert Williams
On 1/4/12 13:33, "Tim Streater"  wrote:


>What I do seem to have is /etc/php.ini.default which I suppose you could
>rename to php.ini if you really wanted to modify it.

Yes, this is correct. I'm not sure if Apple started doing this with Lion
or before, but they give you the .default file to rename (or better, copy)
as php.ini if you desire. Note that the .default file isn't actually used
by PHP, but rather is merely intended to be used as a template.

Also, if I remember right, Apple sets up Apache so that each user has
his/her own config file inside the conf folder. You should make any config
changes, such as turning on PHP, in there, rather than in the primary
config file. The latter is subject to being overwritten on OS updates and
upgrades, while the former is not. Segregating your changes also makes it
easier to tell exactly what you've changed from the defaults.

>I'm however carefully ensuring that the client and server aspects of my
>app (which will both run on the user's machine) don't use anything except
>what comes with the standard OS X distribution, so to fix the date time
>issue I do:
>
>  date_default_timezone_set (@date_default_timezone_get ());

I recommend against this. First of all, in PHP 5.4, this is just going to
return UTC if you haven't explicitly set the time zone, and that's
probably not what you want. Plus, the use of @ here leaves a nasty taste
in the mouth (as it does in most cases).

Instead, I suggest creating a php.ini file and changing this setting there
by setting it to a specific time zone. For example, in mine, I have this
line:

date.timezone = 'America/Phoenix'

This ensures that PHP is always using the same zone no matter what script
is running, avoids PHP errors if you forget to make the change in a
script, avoids you having to modify all your scripts in the first place,
and lets you easily change the time zone used by your applications to
whatever you want independently of the server's own time zone (or in 5.4,
to something other than UTC).


Regards,
Bob
--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/







Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Tim Streater
On 04 Jan 2012 at 14:09, Richard Quadling  wrote: 

> Where do I put my php.ini file for a MacBook Air? I've only had it 2
> days and having trouble with the date.timezone setting.

Hmmm, looks like I haven't got one on my Mini. Which doesn't appear to matter 
as a number of PHP scripts will have been run here in order for you to see this 
mail.

What I do seem to have is /etc/php.ini.default which I suppose you could rename 
to php.ini if you really wanted to modify it. I'm however carefully ensuring 
that the client and server aspects of my app (which will both run on the user's 
machine) don't use anything except what comes with the standard OS X 
distribution, so to fix the date time issue I do:

  date_default_timezone_set (@date_default_timezone_get ());

systematically in my scripts.

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread Bastien


On 2012-01-04, at 10:03 AM, L M Andrews  wrote:

> Hi,
> 
>> Or should I just be looking somewhere else?
> 
> Yes, if you're setting up a local development environment on a Mac, the
> painless solution is to install MAMP ("m" as in Mac). Everything installs
> into a single folder (easily deletable, too) without modifying any of the
> original versions that might have come with OSX.
> 
> There's a free version and a paid pro version here:
> 
> 
> Hope this helps,
> L
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
MAMP is the easiest way to keep it all together and set up. Gets my vote too

Bastien

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread L M Andrews
Hi,

>Or should I just be looking somewhere else?

Yes, if you're setting up a local development environment on a Mac, the
painless solution is to install MAMP ("m" as in Mac). Everything installs
into a single folder (easily deletable, too) without modifying any of the
original versions that might have come with OSX.

There's a free version and a paid pro version here:


Hope this helps,
L



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] New to mac and trying to define a php.ini file.

2012-01-04 Thread TR Shaw

On Jan 4, 2012, at 9:09 AM, Richard Quadling wrote:

> Hi.
> 
> Where do I put my php.ini file for a MacBook Air? I've only had it 2
> days and having trouble with the date.timezone setting.
> 

Open terminal

type

php -i

search for php.ini

you will find it in /etc where is should be on unix.

If you want to keep php up to date and are on Snow (10.6) or Lion (10.7) go to 
http://php-osx.liip.ch/

> I've also had to install xampp (recommended - no idea about it) for
> Apache with PHP.
> 

Why did you do that?  All you had to do was to edit /etc/apache2/httpd.conf to 
turn on php (and don't forget to tu6n on apache via prefs->sharing->websharing

> Different versions of PHP now installed.
> 
> Default from command line is PHP 5.3.6 with Suhosin-Patch (cli)
> (built: Sep  8 2011 19:34:00)
> 
> The one that XAMPP installed is 5.3.1 and I've found the ini file for
> this is in /Applications/XAMPP/xamppfiles/etc/php.ini
> 
> How, can or should I upgrade my PHP to a later release? Oh the joy of
> Windows Binaries

You are on unix. Stuff is usually where it is supposed to be.

Tom


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php