Code Highlighting in WordPress with Symfony2 style

This post is for those blogging on symfony2 and with a self-hosted wordpress.org platform:

Follow these instructions:

install this plugin here http://wordpress.org/extend/plugins/wp-syntax/other_notes/

and also this other plugin

http://wordpress.org/extend/plugins/wp-syntax-hacktify

and download this this stylesheet here

and save it into your wp-content/plugins root folder.

Enable all and use these syntax:

<pre lang="php">
   <?php //your php code or whatever here ?>
and close the pre tag of course ...
<div id="foo">
<?php
  function foo() {
    echo "Hello World!\\n";
  }
 
  $link = $crawler->selectLink('Go elsewhere...')->link();
  $crawler = $client->click($link);
 
  $form = $crawler->selectButton('validate')->form();
  $crawler = $client->submit($form, array('name' => 'Fabien'));
 
// Form submission
$client->request('POST', '/submit', array('name' => 'Fabien'));
 
  // Form submission with a file upload
  $client->request('POST', '/submit', array('name' => 'Fabien'), array('photo' =>'/path/to/photo'));
 
return false;
 
namespace Acme\UserBundle\Entity;
/**
 * @ORM\Entity
 */
class User implements UserInterface
{
    /**
     * @ORM\Column(type="string", length="255")
     */
    protected $username;
 
    // ...
}
?>
{# src/Acme/StoreBundle/Resources/views/Default/index.html.twig #}
 
<form action="{{ path('store_product') }}" method="post" {{ form_enctype(form) }}>
    {{ form_widget(form) }}
 
    <input type="submit" />
</form>
</div>

Leave a Reply

Your email address will not be published. Required fields are marked *