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

ORMs under the hood
Aug 26, 2015 @ 09:55:01

The Vertabelo site has posted a tutorial that gives you an "under the hood" view of ORMs and what they're doing in the background to help make accessing your database information easier.

It often happens that if something is loved, it is also hated with the same power. The idea of object relational mapping fits into this concept perfectly. You will definitely come across many opposite points and fierce discussions as well as unwavering advocates and haters. So if you have ever asked whether to use ORM or not, the answer “it depends” will not be enough.

They start with a definition of an ORM to get everyone on the same page, highlighting how they represent database contents and what some of the benefits are in using them. From there the article talks about the importance of good SQL and a few common dangers in using an ORM and not knowing SQL. Then the article gets into how ORMs work and some of the common design patterns they can implement. It lists some of the more popular ORMs (for Python, Java and PHP) and covers some of the main disadvantages to their use. The article ends with examples of some of the libraries mentioned, highlighting the Propel ORM for the PHP world.

tagged: orm behindthescenes introduction advantages disadvantages types propel example

Link: http://www.vertabelo.com/blog/technical-articles/orms-under-the-hood

Julien Pauli:
Zoom on PHP objects and classes
Mar 26, 2015 @ 12:50:49

Julien Pauli has a recent post to his site that "zooms in" on objects and classes with a look behind the scenes at how they're handled in the PHP source (at the C level) with plenty of code examples and explanations as to how they work.

Everybody uses objects nowadays. Something that was not that easy to bet on when PHP5 got released 10 years ago (2005). I still remember this day, I wasn't involved in internals code yet, so I didn't know much things about how all this big machine could work. But I had to note at this time, when using this new release of the language, that jumps had been made compared to old PHP4. The major point advanced for PHP5 adoption was : "it has a new very powerful object model". That wasn't lies. [...] Here, I will show you as usual how all this stuff works internally. The goal is always the same : you understand and master what happens in the low level, to make a better usage of the language everyday.

The article does a great (if lengthy) job of covering everything that happens with PHP's objects and class system, including stats about memory consumption. He includes both the PHP code and the C code to illustrate what's happening with classes, interfaces, traits and object methods/attributes (including object references). He also talks about what "$this" is and how class destructors are handled.

tagged: object class behindthescenes detail c code memory usage

Link: http://jpauli.github.io/2015/03/24/zoom-on-php-objects.html

/Dev/Hell Podcast:
Episode 50: The Airing of Grievances
Sep 10, 2014 @ 12:05:02

The /Dev/Hell podcast has released their latest episode today - Episode #50: The Airing of Grievances hosted by PHP community members Chris Hartjes and Ed Finkler.


You can listen to this latest episode either through their in-page audio player or by downloading the mp3 (all 53MB of it). If you enjoy the show, be sure to subscribe to their feed to get this and more episodes as they're released.

tagged: devhell podcast ep50 airing grievances origins behindthescenes

Link: http://devhell.info/post/2014-09-09/the-airing-of-grievances/

Sherif Ramadan:
PHP OOP: Objects Under The Hood
Dec 04, 2012 @ 09:15:27

In another of his series looking "under the covers" at what actually happens in the PHP language during its use, Sharif Ramadan has posted this look at the object handling in PHP's OOP functionality.

I would love to take a good long look under the hood at just how PHP objects and classes do the work that they do, and hope that you could benefit from that knowledge. [There are] many questions that come across my desk, on a regular basis, from developers and beginner PHP enthusiasts that I’ve worked with over the years, and are some of the key points this article attempts to help you answer.

He talks about classes "giving birth" to objects, how they're stored internal to PHP and how they provide the "blueprints" for it to lay out the storage of the object's data. He talks about using identifiers for variable/property access, object handlers and how "$this" fits into all of it. He notes that OOP, while a major part of PHP now, wasn't in the initial versions (until around PHP4). He finishes off the post talking about lateral/vertical context switching, the lifecycle of an object and the "early binding problem" and class scope.

tagged: oop language class object detail lowlevel behindthescenes


Ibuildings Blog:
Off-The-Shelf Server Setup
May 30, 2008 @ 08:43:28

On the Ibuildings blog, Ian Barber has a reminder to PHP developers out there used to their servers "just working" because of the popularity of LAMP. He recommends digging a little deeper to the "behind the scenes" of how the server is configured.

PHP programmers generally know what a good systems architecture should look like, but it is often a reality of development that they will have little input on the system itself until the last minute. In fact, it's far from uncommon for a developer to be faced with an off-the-shelf dedicated LAMP server, and left up to their own devices.

He recommends getting to know things like the package manager for your distribution (apt, yum, yast, etc), stripping down the modules your installation is using, check that all of the packages in use need to be enabled and ensure that the network connection is set up correctly and is what you need for the site.

tagged: oftheshelf default installation configuration behindthescenes lamp server