core error

Archive for August 2011

Finally Symfony 2.0 was released. This is one of the most popularPHP framworks and now it has been reinvented with this list of new features:

  • It fully follows the PHP standards
  • Extensively uses dependency injection
  • Big improvement in performance
  • Decoupled in 21components all of the separately available in git

For people coming from symfony1 a cookbook has been created showing how the old version differs from the new one.



In this sample we will create a button to the right of the address bar which will display a fancy popup showing a clock

  1. Create a folder in your hard drive containing two files: manifest.json and popup.html
  2. Add into manifest.json all the information related to your extension. For example: 
      "name": "My First Extension",
      "browser_action": {
        "default_icon": "icon.png",
        "popup": "popup.html"
  3. Add the logic of the extension inside the popup.html file. You can use regular HTML, javascript and CSS. For Example:
    <script type="text/javascript">
       //javascript code to display a clock inside the div
  4. Go to Chrome, click on the    icon, go to Tools > Extensions and load  your unpacked extension from the folder you created
Using Chrome API
Going to this url you can read about all the modules and methods that you can use to enrich your application. For example:
  • chrome.browserAction.setPopup(object details) will let you choose which HTML page to show in the popup (in case you provided more than one)
  • chrome.tabs.executeScript(null, object details) will inject javascript code into the page currently showing in the active tab
  • chrome.tabs.update(null, object updateProperties) will change the properties of the active tab. For example, the url displayed on it


SimpleXML is a PHP extension (enabled by default after PHP 5.1.2) which provides a simple toolset to convert an XML document into an object so it can be easily used by a PHP application


Before PHP5 handling XML documents was quite painful.  With SimpleXML you just need to create one SimpleXMLElement and from that moment on you can use the XML document as it was a regular object where each node is an attribute containing other attributes/nodes.


$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<title>Back to the Future</title>
<name>Dr. Brown</name>
<actor>Christopher Lloyd</actor>
<rating type="stars">5</rating>

$xml = new SimpleXMLElement($xmlstr);
echo $xml->movie[0]->plot;


cURL is a library of calls included in PHP core which allows to fetch data from remote sites. cURL is much safer than doing include or read_file on remote sites.


cURL is specifically designed for this function so you can do much more things than what you could do with include or read_file. For example, you can add specific HTTP options like timeouts and select th HTTP method (GET or POST).



$buffer = curl_exec($curl_handle);

if (empty($buffer)){
    print "<p>Sorry, is down at the moment.</p>";
    print $buffer;

Why PHP is better?

  • wider community support
  • small learning curve
  • support of a big company (Zend Technologies)

Why Python is better?

  • much easier to develop clean code
  • Django is one of the best web framworks out there

Since performance-wise and feature-wise both languages are quite similar we could summarize this topic in one sentence: if we value the support of a big community over the maintainability of our code we should go for PHP. Otherwise we should pick Python.


  • None
  • Justin Cooney: Great comic, this made me laugh!
  • Justin Cooney: Interesting, I didn't know about the Google App Engine, I'm glad I found your article on it!