A few new terms I stumbled upon while reading about Symfony

Magic Methods

Refering to PHP, these are methods that can be used to override the default behavior of classes without modifying the outside code. They are easy to recognize, because the names of the magic methods start with two underscores (__).

For instance, when displaying an object, PHP implicitly looks for a __toString() method for this object to see if a custom display format was defined by the developer:

$myObject = new myClass();
echo $myObject;
// Will look for a magic method
echo $myObject->__toString();

Symfony uses magic methods, so you should have a thorough understanding of them.
Read more about PHP website.

Object-Relational Mapping (ORM)

Databases are relational. PHP 5 and symfony are object-oriented. In order to access the database in an object-oriented way, an interface translating the object logic to the relational logic is required. This interface is called an object-relational mapping, or ORM.

One benefit of an object/relational abstraction layer is that it prevents you from using a syntax that is specific to a given database. It automatically translates calls to the model objects to SQL queries optimized for the current database. This means that switching to another database system in the middle of a project is easy. An abstraction layer encapsulates the data logic.

Propel, another open source project, is currently one of the best object/relational abstraction layers for PHP 5. Symfony integrates Propel seamlessly into the framework, so most of the data manipulation described in this book follows the Propel syntax.

YAML - Yet Another Markup Language

According to the official YAML website, YAML is “a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages.” Put another way, YAML is a very simple language used to describe data in an XML-like way but with a much simpler syntax. It is especially useful to describe data that can be translated into arrays and hashes, like this:

$house = array(
‘family’ => array(
‘name’ => ‘Doe’,
‘parents’ => array(’John’, ‘Jane’),
‘children’ => array(’Paul’, ‘Mark’, ‘Simone’)
),
‘address’ => array(
‘number’ => 34,
’street’ => ‘Main Street’,
‘city’ => ‘Nowheretown’,
‘zipcode’ => ‘12345′
)
);


This PHP array can be automatically created by parsing the YAML string:
house:
family:
name: Doe
parents:
- John
- Jane
children:
- Paul
- Mark
- Simone
address:
number: 34
street: Main Street
city: Nowheretown
zipcode: 12345

In YAML, structure is shown through indentation, sequence items are denoted by a dash, and key/value pairs within a map are separated by a colon. YAML also has a shorthand syntax to describe the same structure with fewer lines, where arrays are explicitly shown with [] and hashes with {}.
Therefore, the previous YAML data can be written in a shorter way, as follows:

house:
family: { name: Doe, parents: [John, Jane], children: [Paul, Mark, Simone] }
address: { number: 34, street: Main Street, city: Nowheretown, zipcode: 12345 }

Bookmark this post: technorati A few new terms I stumbled upon while reading about Symfony delicious A few new terms I stumbled upon while reading about Symfony stumbleupon A few new terms I stumbled upon while reading about Symfony digg A few new terms I stumbled upon while reading about Symfony facebook A few new terms I stumbled upon while reading about Symfony yahoo A few new terms I stumbled upon while reading about Symfony google A few new terms I stumbled upon while reading about Symfony magnolia A few new terms I stumbled upon while reading about Symfony reddit A few new terms I stumbled upon while reading about Symfony windowslive A few new terms I stumbled upon while reading about Symfony

Tags: ,

Related posts

0 Responses to “A few new terms I stumbled upon while reading about Symfony”


  1. No Comments

Leave a Reply




/kapil/blog is Digg proof thanks to caching by WP Super Cache!