php-general Digest 15 Feb 2013 19:04:06 -0000 Issue 8124

Topics (messages 320204 through 320226):

Newbie is trying to set up OOP With PHP and MySQL or MySQLi database class 
(using CRUD)
        320204 by: dealTek
        320209 by: Haluk Karamete
        320211 by: dealTek
        320212 by: Haluk Karamete
        320217 by: Bastien Koert
        320226 by: dealTek

Undefined Variables
        320205 by: Roman Gelfand
        320206 by: Ashley Sheridan
        320207 by: Matijn Woudt
        320210 by: Jan Ehrhardt
        320213 by: Stuart Dallas
        320221 by: Al
        320222 by: Stuart Dallas

Re: openssl_encrypt, ecb and IV
        320208 by: Stephan

PHP fails to install on Ubuntu 12.10. What's going on?
        320214 by: Chris Bergstresser
        320215 by: Daniel Brown
        320218 by: Daniel Brown
        320219 by: John Iliffe
        320220 by: Chris Bergstresser
        320223 by: Andy McKenzie
        320224 by: Daniel Brown

Re: APC opcode cache behavior
        320216 by: Marco Behnke
        320225 by: Camilo Sperberg

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hi everybody,

Newbie is trying to set up OOP With PHP and MySQL or MySQLi database class 
(using CRUD)

Simple story: creating this class database by myself is way over my head. So it 
be best for me to find something on the Internet that has already been created 
and working to pro specs (using CRUD with good security etc).

In my studying, it seems that there is a difference between MySQL and MySQLi - 
MySQLi  being the preferred choice if I understand correctly.

There are lots of examples on the Internet however I don't know enough about it 
to know a good starting example from a bad starting example, so I would much 
appreciate any assistance pointing me towards a good starting point

This seems a good start to me untrained eye, but it seems to be for mysql - not 
mysqli...

http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/

http://www.dreamincode.net/forums/topic/223360-connect-to-your-database-using-oop-php5-with-mysql-and-mysqli/

http://snipplr.com/view/8417/

http://snipplr.com/view/12535/

any assistance is appreciated!

--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]


--- End Message ---
--- Begin Message ---
I recommend a third option, that is PDO.

Start here please. http://net.tutsplus.com/?s=pdo

On Thu, Feb 14, 2013 at 9:49 AM, dealTek <deal...@gmail.com> wrote:
> Hi everybody,
>
> Newbie is trying to set up OOP With PHP and MySQL or MySQLi database class 
> (using CRUD)
>
> Simple story: creating this class database by myself is way over my head. So 
> it be best for me to find something on the Internet that has already been 
> created and working to pro specs (using CRUD with good security etc).
>
> In my studying, it seems that there is a difference between MySQL and MySQLi 
> - MySQLi  being the preferred choice if I understand correctly.
>
> There are lots of examples on the Internet however I don't know enough about 
> it to know a good starting example from a bad starting example, so I would 
> much appreciate any assistance pointing me towards a good starting point
>
> This seems a good start to me untrained eye, but it seems to be for mysql - 
> not mysqli...
>
> http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/
>
> http://www.dreamincode.net/forums/topic/223360-connect-to-your-database-using-oop-php5-with-mysql-and-mysqli/
>
> http://snipplr.com/view/8417/
>
> http://snipplr.com/view/12535/
>
> any assistance is appreciated!
>
> --
> Thanks,
> Dave - DealTek
> deal...@gmail.com
> [db-3]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---

On Feb 14, 2013, at 9:49 AM, dealTek <deal...@gmail.com> wrote:

> Hi everybody,
> 
> Newbie is trying to set up OOP With PHP and MySQL or MySQLi database class 
> (using CRUD)
> 
> Simple story: creating this class database by myself is way over my head. So 
> it be best for me to find something on the Internet that has already been 
> created and working to pro specs (using CRUD with good security etc).
> 
> In my studying, it seems that there is a difference between MySQL and MySQLi 
> - MySQLi  being the preferred choice if I understand correctly.
> 
> There are lots of examples on the Internet however I don't know enough about 
> it to know a good starting example from a bad starting example, so I would 
> much appreciate any assistance pointing me towards a good starting point
> 
> This seems a good start to me untrained eye, but it seems to be for mysql - 
> not mysqli...
> 
> http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/
> 
> http://www.dreamincode.net/forums/topic/223360-connect-to-your-database-using-oop-php5-with-mysql-and-mysqli/
> 
> http://snipplr.com/view/8417/
> 
> http://snipplr.com/view/12535/
> 
> any assistance is appreciated!



An Here Jeffry Way discusses the PDO API

http://net.tutsplus.com/tutorials/php/php-database-access-are-you-doing-it-correctly/






> 
> --
> Thanks,
> Dave - DealTek
> deal...@gmail.com
> [db-3]
> 


--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]


--- End Message ---
--- Begin Message ---
Also worth checking http://justinvincent.com/ezsql
Which is the class behind the WordPress' wpdb class.

This is a great read too ->
http://www.devarticles.com/c/a/MySQL/PHP-and-Databases-for-the-Lazy-Sod/

On Thu, Feb 14, 2013 at 10:30 AM, dealTek <deal...@gmail.com> wrote:
>
>
> On Feb 14, 2013, at 9:49 AM, dealTek <deal...@gmail.com> wrote:
>
>> Hi everybody,
>>
>> Newbie is trying to set up OOP With PHP and MySQL or MySQLi database class 
>> (using CRUD)
>>
>> Simple story: creating this class database by myself is way over my head. So 
>> it be best for me to find something on the Internet that has already been 
>> created and working to pro specs (using CRUD with good security etc).
>>
>> In my studying, it seems that there is a difference between MySQL and MySQLi 
>> - MySQLi  being the preferred choice if I understand correctly.
>>
>> There are lots of examples on the Internet however I don't know enough about 
>> it to know a good starting example from a bad starting example, so I would 
>> much appreciate any assistance pointing me towards a good starting point
>>
>> This seems a good start to me untrained eye, but it seems to be for mysql - 
>> not mysqli...
>>
>> http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/
>>
>> http://www.dreamincode.net/forums/topic/223360-connect-to-your-database-using-oop-php5-with-mysql-and-mysqli/
>>
>> http://snipplr.com/view/8417/
>>
>> http://snipplr.com/view/12535/
>>
>> any assistance is appreciated!
>
>
>
> An Here Jeffry Way discusses the PDO API
>
> http://net.tutsplus.com/tutorials/php/php-database-access-are-you-doing-it-correctly/
>
>
>
>
>
>
>>
>> --
>> Thanks,
>> Dave - DealTek
>> deal...@gmail.com
>> [db-3]
>>
>
>
> --
> Thanks,
> Dave - DealTek
> deal...@gmail.com
> [db-3]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
On Thu, Feb 14, 2013 at 1:24 PM, Haluk Karamete <halukkaram...@gmail.com> wrote:
> I recommend a third option, that is PDO.
>
> Start here please. http://net.tutsplus.com/?s=pdo
>
> On Thu, Feb 14, 2013 at 9:49 AM, dealTek <deal...@gmail.com> wrote:
>> Hi everybody,
>>
>> Newbie is trying to set up OOP With PHP and MySQL or MySQLi database class 
>> (using CRUD)
>>
>> Simple story: creating this class database by myself is way over my head. So 
>> it be best for me to find something on the Internet that has already been 
>> created and working to pro specs (using CRUD with good security etc).
>>
>> In my studying, it seems that there is a difference between MySQL and MySQLi 
>> - MySQLi  being the preferred choice if I understand correctly.
>>
>> There are lots of examples on the Internet however I don't know enough about 
>> it to know a good starting example from a bad starting example, so I would 
>> much appreciate any assistance pointing me towards a good starting point
>>
>> This seems a good start to me untrained eye, but it seems to be for mysql - 
>> not mysqli...
>>
>> http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/
>>
>> http://www.dreamincode.net/forums/topic/223360-connect-to-your-database-using-oop-php5-with-mysql-and-mysqli/
>>
>> http://snipplr.com/view/8417/
>>
>> http://snipplr.com/view/12535/
>>
>> any assistance is appreciated!
>>
>> --
>> Thanks,
>> Dave - DealTek
>> deal...@gmail.com
>> [db-3]
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

The DreamInCode one is good. MySQLi is the recommended option over
MySQL since the mysql one is deprecated. PDO is also a great option
since you can prepare your queries to help sanitize the data

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
On Feb 14, 2013, at 11:46 AM, Bastien Koert <phps...@gmail.com> wrote:

> 
> 
> The DreamInCode one is good. MySQLi is the recommended option over
> MySQL since the mysql one is deprecated. PDO is also a great option
> since you can prepare your queries to help sanitize the data
> 
> -- 
> 
> Bastien



Thanks Bastien,

I imagine this is what you were referring to?

http://www.dreamincode.net/forums/topic/54239-introduction-to-mysqli-and-prepared-statements/

--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]


--- End Message ---
--- Begin Message ---
Is there a performance hit when a variable is undefined? or, perhaps,
aside from the obvious uncontrolled conditions, are there other
impacts?

Thanks in advance

--- End Message ---
--- Begin Message ---

Roman Gelfand <rgelfa...@gmail.com> wrote:

>Is there a performance hit when a variable is undefined? or, perhaps,
>aside from the obvious uncontrolled conditions, are there other
>impacts?
>
>Thanks in advance

Aside from all the warnings and potential logic bombs?

You will have a negligible performance hit with all the isset() checks you'll 
be using, but they won't be noticeable, and its preferred to use them than not 
to avoid issues with missing values.
Thanks,
Ash
http://www.ashleysheridan.co.uk

--- End Message ---
--- Begin Message ---
On Thu, Feb 14, 2013 at 7:04 PM, Roman Gelfand <rgelfa...@gmail.com> wrote:

> Is there a performance hit when a variable is undefined? or, perhaps,
> aside from the obvious uncontrolled conditions, are there other
> impacts?
>
> Thanks in advance


There might be a little performance hit because the error is getting logged
in your webservers logs, though if it is noticeable depends on which
webserver you're using, and how often there are undefined variables.

- Matijn

--- End Message ---
--- Begin Message ---
Matijn Woudt in php.general (Thu, 14 Feb 2013 19:12:55 +0100):
>On Thu, Feb 14, 2013 at 7:04 PM, Roman Gelfand <rgelfa...@gmail.com> wrote:
>
>> Is there a performance hit when a variable is undefined? or, perhaps,
>> aside from the obvious uncontrolled conditions, are there other
>> impacts?
>
>There might be a little performance hit because the error is getting logged
>in your webservers logs, though if it is noticeable depends on which
>webserver you're using, and how often there are undefined variables.

And frameworks like Drupal might intercept the error and store it in the
watchdog file. Then the performance will be degraded.

Jan

--- End Message ---
--- Begin Message ---
Sorry for the top post!

I don't know numbers, but my gut instinct is that the cycles wasted raising the 
notice (it gets raised even if it goes nowhere so turning display and log 
doesn't remove the hit completely) are better spent executing defensive code.

There is no reason, ever, that production code should raise notices about which 
you don't care. If PHP is telling you something might be wrong, something might 
be wrong! And if you're investigating the code already, figure out what's 
happening and deal with it properly.

Only lazy and/or developers ignore notices. If you're one of them and this 
statement offends you, you probably know it's right!

-Stuart

-- 
Sent from my leaf blower

On 14 Feb 2013, at 18:04, Roman Gelfand <rgelfa...@gmail.com> wrote:

> Is there a performance hit when a variable is undefined? or, perhaps,
> aside from the obvious uncontrolled conditions, are there other
> impacts?
> 
> Thanks in advance
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---


On 2/14/2013 1:54 PM, Stuart Dallas wrote:
Sorry for the top post!

I don't know numbers, but my gut instinct is that the cycles wasted raising the 
notice (it gets raised even if it goes nowhere so turning display and log 
doesn't remove the hit completely) are better spent executing defensive code.

There is no reason, ever, that production code should raise notices about which 
you don't care. If PHP is telling you something might be wrong, something might 
be wrong! And if you're investigating the code already, figure out what's 
happening and deal with it properly.

Only lazy and/or developers ignore notices. If you're one of them and this 
statement offends you, you probably know it's right!

-Stuart


I agree with Stuart.

To minimize the overhead of testing every possible undefined variable with isset(), I assign them at the top of the page which uses them. e.g.,

$userInstrHtmlSizeWarning = false;
$currentUserRecArray = array();
if(!isset($_SESSION['pwPassed']))$_SESSION['pwPassed'] = false;

I also have this snippet at the top of my app config file.

if(true){ // TRUE for debug only
  ini_set("display_errors", "on"); //use off if users will see them
  error_reporting(E_ALL)
$error_reporting = '<span style="color:red">Error display and logging on</span> ';
}
else $error_reporting=null;

I put this at a convenient place on the page so I don't forget to turn off the error reporting when the code goes live.

if($error_reporting) echo $error_reporting;

--- End Message ---
--- Begin Message ---
On 14 Feb 2013, at 20:57, Al <n...@ridersite.org> wrote:
> On 2/14/2013 1:54 PM, Stuart Dallas wrote:
>> Sorry for the top post!
>> 
>> I don't know numbers, but my gut instinct is that the cycles wasted raising 
>> the notice (it gets raised even if it goes nowhere so turning display and 
>> log doesn't remove the hit completely) are better spent executing defensive 
>> code.
>> 
>> There is no reason, ever, that production code should raise notices about 
>> which you don't care. If PHP is telling you something might be wrong, 
>> something might be wrong! And if you're investigating the code already, 
>> figure out what's happening and deal with it properly.
>> 
>> Only lazy and/or developers ignore notices. If you're one of them and this 
>> statement offends you, you probably know it's right!
>> 
>> -Stuart
>> 
> 
> I agree with Stuart.
> 
> To minimize the overhead of testing every possible undefined variable with 
> isset(), I assign them at the top of the page which uses them. e.g.,
> 
> $userInstrHtmlSizeWarning = false;
> $currentUserRecArray = array();
> if(!isset($_SESSION['pwPassed']))$_SESSION['pwPassed'] = false;
> 
> I also have this snippet at the top of my app config file.
> 
> if(true){ // TRUE for debug only
>  ini_set("display_errors", "on"); //use off if users will see them
>  error_reporting(E_ALL)
>  $error_reporting = '<span style="color:red">Error display and logging 
> on</span>  ';
> }
> else $error_reporting=null;
> 
> I put this at a convenient place on the page so I don't forget to turn off 
> the error reporting when the code goes live.
> 
> if($error_reporting) echo $error_reporting;

I've used the following method for accessing elements of the global arrays for 
a long time. It saves a lot of typing!

http://stut.net/2011/04/12/php-snippet-array-element-access/

Note that if you're using PHP5 you should remove the & before the $a in the 
function definition.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
Am 24.01.2013 18:08, schrieb Kevin Kinsey:
On Thu, Jan 24, 2013 at 05:55:35PM +0100, steff...@gmx.de wrote:
Hi list,

I am having trouble with error messages saying
"Using an empty Initialization Vector (iv) is potentially insecure and not 
recommended"

These messages turn up using horde which uses ecb. I don't know the inner 
workings of php and openssl but if I understand correctly, there is no IV used 
in ecb hence there should be no error message according to this:
http://svn.php.net/viewvc?view=revision&revision=304179
(I am running php version 5.3.20)

Does anybody have any idea why I am getting these errors ? I can reproduce them 
using this code:

<?php
openssl_encrypt ("Hallo","bf-ecb","abcdef");
?>

Regards
Stephan

Because E_WARNING is issued if the optional fourth parameter, Initialization
Vector, is NULL.

Is that so ? In ext/openssl/openssl.c it looks like php is questioning openssl if the cipher in question needs an iv by calling EVP_CIPHER_iv_length which according to its manpage returns 0 if the cipher does not use an iv. If I understand correctly the warning only gets thrown if the vector is needed and empty. Since ecb does not need an iv this warning should not appear at all, should it ? This is also how I understand the log for the code change:

http://svn.php.net/viewvc?view=revision&revision=304179

How exactly are the error messages troubling you?  If they're appearing on
your site/pages, you should adjust server or site configuration.

That is what I did as a workaround but the question remains why I keep getting the warning with recent versions of php. It doesn't matter if I compile php against the 0.9.8 or the 1.0.1 versions of openssl.

Thanks
Stephan


--- End Message ---
--- Begin Message ---
Hi all --

   I've got a cloud server on Rackspace.  If I bring up a fresh Ubuntu
12.10 machine image, and type "apt-get install php5" it seems to
install fine.  But if I then type "php -version" I get "PHP Parse
error:  syntax error, unexpected end of file in Command line code on
line 1".

   What went wrong?  How can I fix it?

-- Chris

--- End Message ---
--- Begin Message ---
On Thu, Feb 14, 2013 at 2:20 PM, Chris Bergstresser <ch...@subtlety.com> wrote:
> Hi all --
>
>    I've got a cloud server on Rackspace.  If I bring up a fresh Ubuntu
> 12.10 machine image, and type "apt-get install php5" it seems to
> install fine.  But if I then type "php -version" I get "PHP Parse
> error:  syntax error, unexpected end of file in Command line code on
> line 1".
>
>    What went wrong?  How can I fix it?

    Not only is that extremely vague, but it's possibly more of an
issue with Ubuntu's repo than PHP itself.  Nonetheless, try this and
reply to the list with the output of each:

        php -v
        php -r 'echo phpversion().PHP_EOL;'
        php -nv

    Also, while it does work with PHP, note that, with a few
exceptions such as `find`, *NIX CLI short options (single dash)
generally expect a single character, while long options
(double-dashes) take longer strings.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
    Remember to hit reply-all, Andy, so it goes to the list as well as
the previous author.

On Thu, Feb 14, 2013 at 2:49 PM, Andy McKenzie <amckenz...@gmail.com> wrote:
> On Thu, Feb 14, 2013 at 2:29 PM, Daniel Brown <danbr...@php.net> wrote:
>> On Thu, Feb 14, 2013 at 2:20 PM, Chris Bergstresser <ch...@subtlety.com> 
>> wrote:
>>> Hi all --
>>>
>>>    I've got a cloud server on Rackspace.  If I bring up a fresh Ubuntu
>>> 12.10 machine image, and type "apt-get install php5" it seems to
>>> install fine.  But if I then type "php -version" I get "PHP Parse
>>> error:  syntax error, unexpected end of file in Command line code on
>>> line 1".
>>>
>>>    What went wrong?  How can I fix it?
>
> I'm pretty sure the php5 package in ubuntu doesn't include the cli
> client.  Try adding apt-get install php5-cli (or whatever they're
> calling the package these days) and see if the version command works
> then.  Also, you may need a second hyphen before the word version.

    Yes, it would be php5-cli, but since he's getting the response
from PHP (parse error) and not the environment saying the command
isn't found, it shows he's got the CLI installed.  Ubuntu is actually
really helpful with a lot of that, too, since - if it can't find the
command - it'll suggest packages from APT to install which match the
command given.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
On Thursday 14 February 2013 14:20:06 Chris Bergstresser wrote:
> Hi all --
> 
>    I've got a cloud server on Rackspace.  If I bring up a fresh Ubuntu
> 12.10 machine image, and type "apt-get install php5" it seems to
> install fine.  But if I then type "php -version" I get "PHP Parse
> error:  syntax error, unexpected end of file in Command line code on
> line 1".
> 
>    What went wrong?  How can I fix it?
> 
> -- Chris
type php --version

There are two - preceding the word version.

J.

--- End Message ---
--- Begin Message ---
On Thu, Feb 14, 2013 at 3:05 PM, John Iliffe <john.ili...@iliffe.ca> wrote:
> type php --version
>
> There are two - preceding the word version.

   Apparently, the version of PHP installed on 12.04 accepts
"-version".  The version of PHP installed on 12.10 does not, and bombs
without giving a proper error message.
   Good to know.

-- Chris

--- End Message ---
--- Begin Message ---
On Thu, Feb 14, 2013 at 2:52 PM, Daniel Brown <danbr...@php.net> wrote:
>     Remember to hit reply-all, Andy, so it goes to the list as well as
> the previous author.
>
> On Thu, Feb 14, 2013 at 2:49 PM, Andy McKenzie <amckenz...@gmail.com> wrote:
>> On Thu, Feb 14, 2013 at 2:29 PM, Daniel Brown <danbr...@php.net> wrote:
>>> On Thu, Feb 14, 2013 at 2:20 PM, Chris Bergstresser <ch...@subtlety.com> 
>>> wrote:
>>>> Hi all --
>>>>
>>>>    I've got a cloud server on Rackspace.  If I bring up a fresh Ubuntu
>>>> 12.10 machine image, and type "apt-get install php5" it seems to
>>>> install fine.  But if I then type "php -version" I get "PHP Parse
>>>> error:  syntax error, unexpected end of file in Command line code on
>>>> line 1".
>>>>
>>>>    What went wrong?  How can I fix it?
>>
>> I'm pretty sure the php5 package in ubuntu doesn't include the cli
>> client.  Try adding apt-get install php5-cli (or whatever they're
>> calling the package these days) and see if the version command works
>> then.  Also, you may need a second hyphen before the word version.
>
>     Yes, it would be php5-cli, but since he's getting the response
> from PHP (parse error) and not the environment saying the command
> isn't found, it shows he's got the CLI installed.  Ubuntu is actually
> really helpful with a lot of that, too, since - if it can't find the
> command - it'll suggest packages from APT to install which match the
> command given.
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/

Can I just mention, as so many others have, how much I hate the fact
that this list is configured to not reply to the list by default?

Thanks for forwarding this on to the right address, Dan.

-Andy

--- End Message ---
--- Begin Message ---
On Thu, Feb 14, 2013 at 4:56 PM, Andy McKenzie <amckenz...@gmail.com> wrote:
>
> Can I just mention, as so many others have, how much I hate the fact
> that this list is configured to not reply to the list by default?

    I know.  Actually, the only reason it's like this is because a lot
of people will take the conversations off-list on their own, so we
don't force the list as the reply-to address.  After ~13 years,
though, it's difficult to justify the change.

    No problem on the forward, though.  Thanks for contributing to the
community.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
Am 14.02.13 16:05, schrieb Camilo Sperberg:
>
> You can also write a little script that clears the APC cache, something in 
> the line of: 
>
> #!/usr/bin/php
> <?php 
> apc_clear_cache();
>
> And execute this script each time you deploy. (can also be a command such as 
> php -r "apc_clear_cache();"). This way you'll avoid restarting the webserver 
> and it will clear all APC cache forcing APC to cache everything again.

since apache and cli do not share the same apc, it will not work.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz


Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
On 14 feb. 2013, at 20:32, Marco Behnke <ma...@behnke.biz> wrote:

> Am 14.02.13 16:05, schrieb Camilo Sperberg:
>> 
>> You can also write a little script that clears the APC cache, something in 
>> the line of: 
>> 
>> #!/usr/bin/php
>> <?php 
>> apc_clear_cache();
>> 
>> And execute this script each time you deploy. (can also be a command such as 
>> php -r "apc_clear_cache();"). This way you'll avoid restarting the webserver 
>> and it will clear all APC cache forcing APC to cache everything again.
> 
> since apache and cli do not share the same apc, it will not work.
> 
> -- 
> Marco Behnke
> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
> Zend Certified Engineer PHP 5.3
> 
> Tel.: 0174 / 9722336
> e-Mail: ma...@behnke.biz
> 
> Softwaretechnik Behnke
> Heinrich-Heine-Str. 7D
> 21218 Seevetal
> 
> http://www.behnke.biz
> 
> 

Oh true, sorry, I totally forgot.

In that case, you can always do a wget or cURL request to your server forcing 
it to clean APC cache through the webserver, I assume that if you're deploying 
through symlinks you want a really minimal downtime during update, the only bad 
thing about this method is that you need to protect the script from external 
visitors through htaccess or similar methods if you're using other webservers. 
Make the request like: 
wget http://localhost/apc-clear.php -O /dev/null 2>&1

man wget for more information about how to use always the correct options.


If you are using Apache, you can also give a try with a graceful restart, in 
red hat based systems, you would restart apache with:
/etc/init.d/httpd graceful
or
apachectl graceful

I have never tried this on a production machine so I really don't know if that 
is gonna work, but the idea after this method is to: 
"The USR1 or graceful signal causes the parent process to advise the children 
to exit after their current request (or to exit immediately if they're not 
serving anything)."
http://httpd.apache.org/docs/2.2/stopping.html#graceful

Hope this helps ^^

Met vriendelijke groet,
Camilo Sperberg

----------------
W: http://unreal4u.com
T: http://twitter.com/unreal4u


--- End Message ---

Reply via email to