 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Systems Architect Blog: Apache2 vs Nginx for PHP application
by Chris Cornutt March 29, 2013 @ 10:41:38
On the Systems Architect blog there's a recent post from Lukasz Kujawa about comparing Apache2 and Nginx for PHP applications, specifically when using the PHP-FPM module. His tests are based on the results from three different application types - a large Zend Framework 1 app, a small PHP script and a WordPress installation.
If you've ever been trying to squeeze more out of hardware you must have come across Nginx (engine x). Nginx usually appears in context of PHP-FPM (FastCGI Process Manager) and APC (Alternative PHP Cache). This setup is often pitched to be the ultimate combo for a web server but what that really means? How much faster a PHP application is going to be on a different web server? I had to check it and the answer as often is - that depends.
He ran the tests on an Amazone EC2 instance and optimized the server to ensure that there was a little interference as possible. The used the Zend Optimizer Plus opcode cache and PHP 5.4 and set the logs to go to memory instead of disk. Graphs included in the post show the results of the benchmarking of each application, with the differences (in most cases) not being that wide of a gap.
There isn't big difference between Apache2 and Nginx in PHP context. Yes, Nginx can be much faster when delivering static content but it won't speed up PHP execution. Running a PHP script seams to be so CPU challenging task that it completely eclipse any gain from a web server.
voice your opinion now!
apache2 nginx performance benchmark zendframework1 wordpress native
Timothy Boronczyk: PHP Assertions
by Chris Cornutt November 08, 2012 @ 11:43:49
Timothy Boronczyk has written up a new post that looks at using assertions in PHP - the actual use of the assert function to evaluate values in your code.
I stumbled upon assertions in PHP today, though why I didn't know they existed after working with the language for so long and what I was looking for originally when I came across them are both mysteries. And with the increasing focus on software quality in the PHP community, I wondered why I hadn't seen them used by others. I decided to ask around, look into PHP's implementation of assertions, and do some tinkering.
He talks some about their usage, some of the common issues surrounding them and compares using them directly on return values vs evaled strings. He also includes an implementation of them in a bit of sample code - a class that uses them (and an assertion callback) to handle the throwing of exceptions.
Assertions are meant to identify program logic/design bugs, not as a run-time error handling mechanism. Isn't this why we do unit testing? Playing devil's advocate, what's wrong with pushing unit tests directly into your code if we have doc comments that are extracted for documentation?
voice your opinion now!
assertions native function overview exception error
Miro Svrtan: PHP Fatal errors into exceptions natively
by Chris Cornutt August 28, 2012 @ 10:08:39
Miro Svrtan has a new post today proposing something that could be added to help handle bad method calls in PHP apps - using the BadMethodCallException (pre-existing) instead of throwing fatal errors.
Using getter method that is not implemented will get you fatal error saying how undefined method is called and request will stop. [...] On the other hand if you would use public property all you would get is a notice saying how this property does not exist and rest of request would be completed. [...] I know that this is due to dynamic typing behavior of PHP and no I am not suggesting raising a notice if undefined method gets called but since 5.1.0 there is a BadMethodCallException class which would be perfect for this situation.
There's been other people that have proposed the same idea as a bug, but nothing formal has been submitted as an RFC to make the change. Miro is looking for feedback to find if others would be interested in this feature and want to make the proposal (leave comments here).
voice your opinion now!
exception native badmethodcallexception fatal error rfc
Nikita Popov's Blog: A plea for less (XML) configuration files
by Chris Cornutt July 10, 2012 @ 10:09:27
Nikita Popov has posted a plea to developers and project maintainers alike to stop using XML for their configuration files in their PHP-based applications.
I recently tried using Phing (a PHP build system) to do some simple release automation. Just creating a PEAR package and doing a few string replacements here and there. The result? After several wasted hours I ended up using Phing only for PEAR packaging and doing everything else in a custom PHP build script. The reason? Phing uses XML files to configure what it should do during a build.
He advocates a more native solution - a PHP script that defines the configuration options as a part of an object that can be injected into the parts of your app without the need for external dependencies.
voice your opinion now!
configuration file xml native object opinion
Symfony Blog: Symfony2 Annotations gets better
by Chris Cornutt May 23, 2011 @ 11:08:53
Fabien Potencier has posted another in his "getting better" series looking at the features that are included in the Symfony2 framework. In this new post he talks about the improvement annotation support.
Later today, I will release Symfony2 beta2. But first, I wanted to talk about a big change that landed into master yesterday. As you might know, Symfony2 uses annotations for Doctrine mapping information and validation configuration. Of course, it is entirely optional, and the same can be done with XML, YAML, or even PHP. But using annotations is convenient and allows you to define everything in the same file.
Two new bundles were added, SensioFrameworkExtraBundle and JMSSecurityExtraBundle, that let you use annotations in the controller for configuration. Examples of this new feature are included in the post giving the configuration settings a more "native" feel.
voice your opinion now!
annotations native controller configuration
Shay Ben Moshe's Blog: PHP's native array vs SplFixedArray performance
by Chris Cornutt April 28, 2011 @ 09:06:01
Shay Ben Moshe has put together a quick post today where he benchmarks array handling performance differences between PHP's native array and the newer SplFixedArray data structure that's a part of the Standard PHP Library that comes with any recent version of the language.
In PHP, arrays are one of the most fundamental data structures.
We use them everywhere.
They are very flexible, because they are implemented as associative arrays, and therefore let us use both string and integer keys. They are also unlimited in size, in most languages arrays are fixed-sized, but this is not the case in PHP. With that in mind, there still is a drawback. It damages performance. The solution for this problem may be SplFixedArray. But, it is not a perfect solution.
He points out two major differences - the SplFixedArray is, well, a fixed size and the fact that it can only use integer keys (no associative arrays here). He created three tests to compare the performance of the two:
- Writing data to the array
- Reading data from the array
- Getting a random value from the array
Each of these are measured in terms of runtime and/or memory usage. If you'd like to try out the tests for yourself, you can download the files needed. I won't cover the results of the tests here, though - you'll need to visit the post for that!
voice your opinion now!
native array splfixedarray performance benchmark runtime memory
Kore Nordmann's Blog: Native parallel PHP job queue
by Chris Cornutt May 07, 2010 @ 14:40:29
Kore Nordmann has put together some scripts that will let you create a native parallel job queue using only PHP (and the PCTNL extension).
To make use of multiple cores for some rather long processing operations I needed a way to fork multiple workers from a single PHP script multiple times lately. So I created a small project on github which implements this in a way, so that it should reusable by anybody. This is far from being rocket science, but still might be useful to someone out there.
He uses the ShellJobProvider (extended from JobProvider) to handle the creation of the tasks. His simple example just spawns off a few echo statements and pushes the results to some files. You can get these libraries from hos github account. You'll need PHP 5.3 and the PCTNL extension installed to get it working.
voice your opinion now!
native parallel job queue pctnl
Brandon Savage's Blog: Why Great Development Tools Don't Seem To Be Written In PHP
by Chris Cornutt December 04, 2009 @ 09:06:13
In a new post to his blog Brandon Savage asks why some of the best development tools don't seem to be written in PHP.
Trac. CruiseControl. phpUnderControl. Jira. Bugzilla. These are all intensely popular development tools. And not a single one of them is written in PHP. Why? [...] Some might argue that PHP is a lesser language, and thus incapable of producing the results that Python and Java can produce. Others might argue that other languages are more mature. But the truth is that these applications don't exist in PHP simply because PHP wasn't previously capable of producing them.
He expresses a desire to work on some of these tools and to make them native to PHP, but several comments on the post steer him towards some projects that have already done this sort of thing including Xinc, ArbitTracker and sismo.
voice your opinion now!
development tool native opinion
Brandon Savage's Blog: Exceptional PHP Nesting Exceptions In PHP
by Chris Cornutt November 12, 2009 @ 12:43:48
Brandon Savage continues his introductory series on exception handling in PHP with this new post to his blog. This time the focus is on methods for nesting exceptions.
In the last two entries we have talked about the concept of layer abstraction: that is, that exceptions should not be allowed to pass out of one layer and into another. So, when an exception is raised in the database layer it should be caught in the controller. But how do we go about making sure that exceptions raised in the database layer are properly recorded and processed, ensuring that we have error logging and don't simply silence our exceptions?
He looks first at general exception nesting then at extending the base Exception class to write more nested code (inside a class). He also touches on the nested exceptions that were included in the latest release of the PHP 5.3 series.
voice your opinion now!
exception nesting tutorial native
|
Community Events
Don't see your event here? Let us know!
|