php-general Digest 5 Sep 2013 10:48:00 -0000 Issue 8357
php-general Digest 5 Sep 2013 10:48:00 - Issue 8357 Topics (messages 322039 through 322046): Re: Static utility class? 322039 by: Stephen 322040 by: Micky Hulse 322043 by: Rodrigo Santos 322044 by: Micky Hulse 322045 by: Robert Cummings Re: message to user after complete POST 322041 by: Rodrigo Santos 322042 by: iccsi Re: PHP-5.5.2 +opcache segfaults with Piwik 322046 by: Grant 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 -- ---BeginMessage--- On 13-09-04 05:09 PM, Micky Hulse wrote: Thank you so much for the quick and very informative/educational replies Stephen and David, I really appreciate it! :) On Wed, Sep 4, 2013 at 12:36 PM, Stephen stephe...@rogers.com wrote: This sounds simply like a library of functions that are implemented using objects. Instantiate your static variables in the library file. Again, so that only happens once. functions implemented using objects sounds like exactly what I want. Just out of curiosity, and sorry in advance for my ignorance, but does the code I posted fit that type of pattern? If not, what would I need to modify and how would I call it? Actually, I should probably spend some time Googling before I ask you for more details. :D Well, your code does not take advantage of the features of classes, but the syntax is correct. Global, static variables are not consistent with the design concepts of OOP. But as a first step in moving from procedural code to OOP, which is learning the syntax, go for it. -- Stephen ---End Message--- ---BeginMessage--- Thanks Stephen! I really appreciate the help! :) In my PHP ventures over the years, I haven't made much use of static variables/methods/properties ... I was thinking they might be useful for this one bit of code, but based on your feedback (and David's) I think I'll be heading down a different path. Thanks again for the kick in the right direction! Much appreciated! Cheers, Micky ---End Message--- ---BeginMessage--- Hi, first, sorry for the bad English. Yes, at least, as far as I know, this is the perfect way to do what you want to do. Think like this: when you instanciate a class, you are allocating memory. If you don't need any information stored, then you don't need to allocate memory, right? So, it's is logic to have a class that you will call only one fragment when you need it, rather than load the entire class just for one method. Just be careful to organize your utility methods by by meaning. Don't put a method that make dating stuff and a method that write a random string in the same class. By doing so, you are breaking the object orientation purpose. 2013/9/4 Micky Hulse mickyhulse.li...@gmail.com Hi all! Example code: https://gist.github.com/mhulse/6441525 Goal: I want to have a utility class that contain utility methods which should have the option of being called multiple times on a page. I think my main goal is to avoid having to new things ... I don't really need to create an instance here (there's no need for a constructor in this case). Question: Is the above simple pattern a good way to have a class that calls static methods? To put it another way, is there any reason why I would not want to use the above code? Basically I want to wrap these simple functions in a nice class wrapper and have the ability to call them without having to jump through more hoops than is necessary. Are there any pitfalls to writing a class like this? Or, is this the standard way of writing a simple utility class for this type of situation? Please let me know if I need to clarify my questions. Thanks for your time? ---End Message--- ---BeginMessage--- Hi Rodrigo, thanks for the help, I really appreciate it! On Wed, Sep 4, 2013 at 5:55 PM, Rodrigo Santos rodrigos.santo...@gmail.com wrote: Hi, first, sorry for the bad English. Not bad at all! Very clear and well written reply (heck, it's better than my native English writing), so thank you! :) Yes, at least, as far as I know, this is the perfect way to do what you want to do. Think like this: when you instanciate a class, you are allocating memory. If you don't need any information stored, then you don't need to allocate memory, right? So, it's is logic to have a class that you will call only one fragment when you need it, rather than load the entire class just for one method. Interesting! That makes a lot of sense. Now you've piqued my interests! :) I was going to head down a different path, but you've inspired me to further explore the use of static methods/properties/variables/other. A part of me just wants to learn more about PHP OOP, and using static members is
Re: [PHP] Static utility class?
On 13-09-04 09:06 PM, Micky Hulse wrote: Hi Rodrigo, thanks for the help, I really appreciate it! On Wed, Sep 4, 2013 at 5:55 PM, Rodrigo Santos rodrigos.santo...@gmail.com wrote: Hi, first, sorry for the bad English. Not bad at all! Very clear and well written reply (heck, it's better than my native English writing), so thank you! :) Yes, at least, as far as I know, this is the perfect way to do what you want to do. Think like this: when you instanciate a class, you are allocating memory. If you don't need any information stored, then you don't need to allocate memory, right? So, it's is logic to have a class that you will call only one fragment when you need it, rather than load the entire class just for one method. Interesting! That makes a lot of sense. Now you've piqued my interests! :) I was going to head down a different path, but you've inspired me to further explore the use of static methods/properties/variables/other. A part of me just wants to learn more about PHP OOP, and using static members is something I've not explored much. Seems like a simple functional utility class would be a good time to play and learn more. :D Just be careful to organize your utility methods by by meaning. Don't put a method that make dating stuff and a method that write a random string in the same class. By doing so, you are breaking the object orientation purpose. Excellent tip! Thank you Rodrigo! I really appreciate the tips/advice and inspiration. :) I'll second Rodrigo's opinion, but would like to comment that the name of the class is misleading since it's called Singleton. The singleton pattern is used when you only ever want one instantiation of a class. In your case you are using static methods, the object never needs to be instantiated and so it doesn't fit this pattern. What you are creating is far more consistent with the utility pattern. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik
I've tried php-5.5.2 and 5.5.3 but both segfault with piwik unless the opcache is disabled. Someone filed a piwik bug but was told it's a php bug: http://dev.piwik.org/trac/ticket/4093 - Grant Is this a known issue? - Grant Is there anything I can do? - Grant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static utility class?
On Wed, Sep 4, 2013 at 11:07 PM, Robert Cummings rob...@interjinn.com wrote: I'll second Rodrigo's opinion, but would like to comment that the name of the class is misleading since it's called Singleton. The singleton pattern is used when you only ever want one instantiation of a class. In your case you are using static methods, the object never needs to be instantiated and so it doesn't fit this pattern. What you are creating is far more consistent with the utility pattern. Ahhh, thanks so much for the clarification and details! That's very helpful. I've updated my gist to reflect the pattern name: https://gist.github.com/mhulse/6441525 Much appreciated. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static utility class?
On Thu, Sep 5, 2013 at 12:15 PM, Robert Cummings rob...@interjinn.com wrote: Probably sufficient (and easier for typing) to just call it Utility since it follows the pattern but isn't the pattern itself :) Good call! Updated the example code. Thanks again! I really appreciate the help. :) Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dependency Injector
Jee, that should have been a friday comment...how does your dic standout On Thu, Sep 5, 2013 at 4:06 PM, Sorin Badea sorin.bade...@gmail.com wrote: There are few tutorials about home made dic. How does your dic stand out from the crowd ? Regards. On Thu, Sep 5, 2013 at 10:56 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Hello people, I want to share with you a simple and small Dependency Injector made for me. https://github.com/abloos/Sofia Regards -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar -- Sorin Badea - Software Engineer -- Bastien Cat, the other other white meat
Re: [PHP] PHP Dependency Injector
Sorry guys if disturbed. 2013/9/5 Bastien Koert phps...@gmail.com Jee, that should have been a friday comment...how does your dic standout On Thu, Sep 5, 2013 at 4:06 PM, Sorin Badea sorin.bade...@gmail.comwrote: There are few tutorials about home made dic. How does your dic stand out from the crowd ? Regards. On Thu, Sep 5, 2013 at 10:56 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Hello people, I want to share with you a simple and small Dependency Injector made for me. https://github.com/abloos/Sofia Regards -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar -- Sorin Badea - Software Engineer -- Bastien Cat, the other other white meat -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar
Re: [PHP] PHP Dependency Injector
Thanks Sorin, I will do that and I will have more care the next time. You have no reason to apologize. You shared a project you made by yourself, way to go. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dependency Injector
On Thu, Sep 5, 2013 at 1:40 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Thanks Sorin, I will do that and I will have more care the next time. You can also check out Pimple [1] by the creator of the Symfony Framework. Peace, David [1] http://pimple.sensiolabs.org/
Re: [PHP] PHP Dependency Injector
There are few tutorials about home made dic. How does your dic stand out from the crowd ? Regards. On Thu, Sep 5, 2013 at 10:56 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Hello people, I want to share with you a simple and small Dependency Injector made for me. https://github.com/abloos/Sofia Regards -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar -- Sorin Badea - Software Engineer
Re: [PHP] PHP Dependency Injector
Juan, the problem with this list is that that there are too damn many dumb questions. You did something nice but it doesn't stand out. You can check Symfony2 DiC. You can use it as a stand alone component. On Thu, Sep 5, 2013 at 11:30 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Sorry guys if disturbed. 2013/9/5 Bastien Koert phps...@gmail.com Jee, that should have been a friday comment...how does your dic standout On Thu, Sep 5, 2013 at 4:06 PM, Sorin Badea sorin.bade...@gmail.comwrote: There are few tutorials about home made dic. How does your dic stand out from the crowd ? Regards. On Thu, Sep 5, 2013 at 10:56 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Hello people, I want to share with you a simple and small Dependency Injector made for me. https://github.com/abloos/Sofia Regards -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar -- Sorin Badea - Software Engineer -- Bastien Cat, the other other white meat -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar -- Sorin Badea - Software Engineer
Re: [PHP] Static utility class?
On 13-09-05 02:27 PM, Micky Hulse wrote: On Wed, Sep 4, 2013 at 11:07 PM, Robert Cummings rob...@interjinn.com wrote: I'll second Rodrigo's opinion, but would like to comment that the name of the class is misleading since it's called Singleton. The singleton pattern is used when you only ever want one instantiation of a class. In your case you are using static methods, the object never needs to be instantiated and so it doesn't fit this pattern. What you are creating is far more consistent with the utility pattern. Ahhh, thanks so much for the clarification and details! That's very helpful. I've updated my gist to reflect the pattern name: https://gist.github.com/mhulse/6441525 Much appreciated. :) Probably sufficient (and easier for typing) to just call it Utility since it follows the pattern but isn't the pattern itself :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dependency Injector
On Thu, Sep 05, 2013 at 04:19:18PM -0400, Bastien Koert wrote: Jee, that should have been a friday comment...how does your dic standout Don't send emails like that to the list when I've got a mouthful of water! It all came out my nose! ;-} Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dependency Injector
Thanks Sorin, I will do that and I will have more care the next time. Regards 2013/9/5 Sorin Badea sorin.bade...@gmail.com Juan, the problem with this list is that that there are too damn many dumb questions. You did something nice but it doesn't stand out. You can check Symfony2 DiC. You can use it as a stand alone component. On Thu, Sep 5, 2013 at 11:30 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Sorry guys if disturbed. 2013/9/5 Bastien Koert phps...@gmail.com Jee, that should have been a friday comment...how does your dic standout On Thu, Sep 5, 2013 at 4:06 PM, Sorin Badea sorin.bade...@gmail.comwrote: There are few tutorials about home made dic. How does your dic stand out from the crowd ? Regards. On Thu, Sep 5, 2013 at 10:56 PM, Juan Sebastian Scatularo sebastianscatul...@gmail.com wrote: Hello people, I want to share with you a simple and small Dependency Injector made for me. https://github.com/abloos/Sofia Regards -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar -- Sorin Badea - Software Engineer -- Bastien Cat, the other other white meat -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar -- Sorin Badea - Software Engineer -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar
[PHP] PHP Dependency Injector
Hello people, I want to share with you a simple and small Dependency Injector made for me. https://github.com/abloos/Sofia Regards -- Facebook: www.facebook.com/JuanSebastianScatularo Twitter: www.twitter.com/js_scatularo Web: www.sebastianscatularo.com.ar