News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Why Choose PHP Over Alternatives?
February 24, 2014 @ 11:25:45

On the SitePoint PHP blog Bruno Skvorc has a new article with a few of the reasons why to choose PHP over other alternatives. It's a quick post with only a few points, but it's interesting for its choices of when not to use PHP.

It's a popular question. Why indeed should one pick PHP over one of the alternatives? After all, PHP has often been dismissed as a unusable and badly designed language. Why would anyone choose it, when starting a project from scratch? Instead of listing the reasons why people do choose it (mostly widespread availability), let's instead focus on why people should choose it. We can't talk about that, however, without first mentioning why they shouldn't.

Among their suggestions of when not to use PHP are things like building command line applications and "just because it's there" on your shared hosting. There's a section near the end of the article that talks about some of the work that's been done to try to dispel the "bad press" PHP has gotten and how other languages (his illustration is Javascript) have the same kind of taunting and nitpicking happening as well.

0 comments voice your opinion now!
choice alternative opinion language

Link: http://www.sitepoint.com/why-choose-php/

Engine Yard Blog:
Alternative PHP Implementations
December 17, 2013 @ 11:45:09

On the Engine Yard blog they've posted a guest article from PHP community member Chris Hartjes about some of the alternative PHP implementations that are out and available to the community.

Many PHP developers have a very vague understanding of what is meant by a "runtime". It's a concept that is more common in other languages languages. At it's most basic level, it is the idea that you can have a specification for the behaviour of the language, and then you can write your own implementation of it. [...] A shocking fact: programming languages have bugs and are sometimes missing features that people desire. Alternative implementations are a great way for people to try and create a version of a language that meets their needs while hopefully remaining as backwards compatible as possible.

He talks about one of the major players in the "alternate PHP" realm right now - the HipHop Virtual Machine (or HHVM) from Facebook. The project looks to make PHP perform even better than it already does by compiling it down. Chris shares two reasons he thing they started the project - one being their own need for performance and the other being that it gives them the option of adding new features to the language they might need.

0 comments voice your opinion now!
alternative implementation facebook hiphop vm hhvm

Link: https://blog.engineyard.com/2013/alternative-php-implementations

Qandidate.com:
Using Satis for fast and reliable software deployment
December 05, 2013 @ 11:57:32

One of the major recent advancements in the PHP ecosystem has been the use of Composer (and the Packagist service) for package and dependency management. Unfortunately, this default setup comes with one big limitation - if the Packagist or Github are unavailable for some reason, your Composer install will fail, possibly leaving you dead in the water. So, what can you do to help? On the Qandidate.com blog today they introduce you to Satis and how to integrate it into your deployment process.

If you're familiar with Composer you know it can be slow and sometimes unreliable when one or more packages are not available. Every time you run composer update Composer will access Packagist to check for new versions of the packages you use. When it finds new releases it will access GitHub, BitBucket (or wherever the packages are hosted) to download your packages.

Satis is a "private Packagist" and provides the data Composer needs to fetch and integrate either your internal packages or mirrors of external ones you've created. They help you get it installed, configured and show how to build and serve up the information via PHP's own built-in web server. They also touch on a few other related points - the speed of Satis, reliability and some concerns around securing your installation.

0 comments voice your opinion now!
satis introduction packagist composer alternative private package

Link: http://labs.qandidate.com/blog/2013/12/05/using-satis-for-fast-and-reliable-software-deployment/

Mathias Verraes:
Verbs in Class Names
October 07, 2013 @ 11:40:07

Mathias Verraes has an interesting post to his site suggesting that using verbs in class names can make for easier to understand and easier to read code - more "natural language."

When you first learned Object Oriented Programming, somebody probably told you that objects map to things. And that still holds true most of the time. And maybe somebody explained it using the simple heuristic to "look for the nouns", which can indeed be a great discovery technique. But then somebody probably phrased that as "class names should not have verbs in them". To me, that rule is severely limiting the possibilities for your models. So here are some cases where I prefer to use verbs.

He suggests that class names, in some cases, could be used as "messages" to the developers using them in the OOP. He includes some suggestions (based on the suggestion of nouns from another post) that use verb-names to convey what they're doing. He also talks about three specific cases - specifications, exceptions and interfaces - and includes samples of each using this idea of verb-based class names.

0 comments voice your opinion now!
verb class naming noun alternative example

Link: http://verraes.net/2013/10/verbs-in-class-names/

SitePoint PHP Blog:
Coding a Lorem Ipsum Alternative
August 26, 2013 @ 10:54:02

On the SitePoint PHP blog David Francis has written up an example showing how to create a "lorem ipsum" alternative in PHP. The "lorem ipsum" functionality generates text to put into layouts or prototypes of pages. It's named this way because the first two words are traditionally "lorem ipsum."

Lorem Ipsum generators are well known and are useful for generating text copy during website development. [...] t's good that we have a wide selection of text generators, but how exactly are these generators made? Can we use PHP and MySQL to build our own? That's exactly what we'll tackle in this article. We won't develop a fully working website; what we will cover are the essentials for building a site such as Fillerati.

He suggests using something from Project Gutenberg (a collection of public domain books and other written works) with the HTML markup already included. His personal choice is On the origin of the Species. He uses a simple PHP script to extract the content from the downloaded document to find useable paragraphs (don't want ones that are too long or short). He then takes that same data and populates a few database tables with it and includes the script to extract them and place them in the page. This could easily be adapted into a view helper for your favorite templating language or framework.

0 comments voice your opinion now!
loremipsum alternative projectgutenburg tutorial html extract

Link: http://www.sitepoint.com/coding-a-lorem-ipsum-alternative/

Marco Pivetta:
Accessing private PHP class members without reflection
August 15, 2013 @ 12:53:55

Marco Pivetta has posted about an interesting trick you can do with closures in PHP related to accessing private properties inside classes.

A couple of weeks ago I was working on a very tricky issue on ProxyManager. The problem is simple: instantiating ReflectionClass or ReflectionProperty is slow, and by slow, I mean really slow! The reason for this research is that I'm trying to optimize a "hydrator" to work with larger data-sets by still keeping a low initialization overhead. PHP 5.4 comes with a new API for Closures, which is Closure#bind(). Closure#bind() basically allows you to get an instance of a closure with the scope of a given object or class. Neat! That's basically like adding APIs to existing objects! Let's break some OOP encapsulation to fit our needs.

He shows how to use this "bind" feature to reach into an object, in this case a "Kitchen", and extract the value of an internal, private property. He also talks some about the performance of this method versus the more typical use of Reflection. He includes two other quick examples too - accessing the same private properties by reference and an abstracted "property reader" closure that uses the bind trick on any object.

0 comments voice your opinion now!
private method reflection closure bind alternative performance

Link: http://ocramius.github.io/blog/accessing-private-php-class-members-without-reflection

Tom Butler:
PHP PSR-0 Pretty Shortsighted, Really
April 16, 2013 @ 13:12:14

In a new post to his site Tom Butler gives some reasoning as to why he thinks PSR-0 is shortsighted and some examples of a possible better alternative.

A little background for those unaware of what PSR-0 is: There's a self-declared PHP "standards" group called PHP-FIG attempting to push several "standards" throughout the PHP community. [...] I have little interest in debating the politics behind pushing standards or whether small groups of developers trying to make decisions that affect the entire community is good or not, but I do object to the PSR-0 standard itself. My issues are purely practical, PSR-0 reduces flexibility and makes life more difficult for developers

While he likes the idea of a standard way to be able to include third-party libraries that can be reused in multiple systems, he suggests that it answers the wrong question. In his view, it should be up to the library/tool developers to ensure the structure of their code to work with a standard, not the other way around. He points out that a "standard" is something that should apply to all situations and some of the workarounds that are needed for PSR-0 negate this idea.

In his alternative method, he suggests an "Autloadable" interface that can be implemented by the library/tool that includes a "load" method to handle the actual class loading. Then this autoloader would be registered via a json configuration file for the package. This allows the developer to control the loading and place any exceptions they might need into their own logic instead of trying to work around possible issues with the PSR-0 loading scheme.

PSR-0 is a bad solution to a good problem. If you take anything from reading this post, remember this: If the standard defined how autoloaders could be extended, rather than how autoloaders worked, then each library or vendor could provide its own extension to the autoloader and everyone would be happy.
0 comments voice your opinion now!
psr0 autoload standard opinion shortsighted alternative

Link: http://r.je/php-psr-0-pretty-shortsighted-really.html

Community News:
Nomad PHP - the Virtual PHP User Group
April 09, 2013 @ 12:41:21

If you've wanted to get involved in a PHP user group but either don't have one in your area or travel so much it makes it impractical, there's a new group that might interest you - Nomad PHP. It's a virtual user group that you can attend. It's still in the beginning stages, but you can express your interest and get more details as they come.

Tired of seeing all the great speakers other PHP User Groups are hearing and lamenting that there is no group near you? Nomad PHP User Group is just for you. We meet on-line, so you can participate wherever you are [and] will have well known as well as brand new speakers. You'll also get access to the recordings to review later.

They point out that this isn't intended as a replacement for a local user group if you have one - interaction with peers and being a part of the community is still important. This is just an alternative. If this sounds interesting, head over and enter your information to be contacted with more info about the group.

0 comments voice your opinion now!
usergroup nomadphp virtual alternative online

Link: http://nomadphp.com

PHPMaster.com:
Avoid the Original MySQL Extension, Part 1
February 15, 2013 @ 11:13:29

On PHPMaster.com today there's a new post, the first in a series, about avoiding the original MySQL extension in favor of what mysqli has to offer. The cover some of the basics of the extension and include code showing its use.

Experienced developers eschew the original MySQL extension because of its abandoned status in PHP. Nascent web developers, however, may be completely oblivious to its dormant past and dying future. [...] It is therefore the intention of this two-part article to raise awareness among developers who still use the MySQL extension, inform them of its problems, and to help them switch over to an alternative extension.

They start with a brief look at the "what's wrong" with the MySQL extension (including its upcoming deprecation). The article then gets into the basics of MySQLi and how to do things like make a connection and run a few queries. There's also a bit about prepared statements and the built-in ability to do "multi-queries" (complete with rollbacks).

0 comments voice your opinion now!
mysql extension avoid mysqli introduction tutorial alternative


Rob Allen:
Sending an HTML with text alternative email with ZendMail
November 02, 2012 @ 10:26:20

Rob Allen has a quick tutorial posted to his site today showing you how to send an email with the ZendMail component of the Zend Framework 2 that contains HTML but provides a plain text backup in the same message.

Sending a multi-part email with ZendMail is easy enough, but if you want to send an HTML email with a text alternative, you need to remember to set the content-type in the headers to multipart/alternative. As this is the second time I had to work this out, I'm noting it here for the next time I forget!

The rest of the post is the code you'll need to send a simple email with a text and HTML body sections, configure the headers (to, from, etc) and the "multipart/alternative" header to make the HTML or plain text switching work correctly.

0 comments voice your opinion now!
zendframework2 mail tutorial send alternative html plaintext



Community Events





Don't see your event here?
Let us know!


release package series framework podcast community deployment install zendserver introduction tips update list laravel opinion library api language symfony interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework