Framework apathy? Daft plugins? Blog time!

It has been a while since my last blog post, which could either be put down to long hours at work or my general apathy towards Symfony following on from Francois’ odd series of posts about the management and direction of the framework.  I guess it doesn’t help that I haven’t been given the opportunity yet to let loose my Symfony skills on a client project, although I do try to keep up to date with 1.1 and the onslaught of core trunk commits.  I desperately don’t want to lose interest in this framework, but my view is that there is more than enough drama on the internet and the last thing the Symfony community needs is a big split down the middle.

Anyhoo, whilst I’m in quasi-rant mode, I just thought I’d comment on the state of the plugin repository as of late.  I, for one, never really understood why the ’sf’ prefix was dropped from non-core plugins, as it didn’t really do any harm.  There was never any kind of quality control put in place when the devs opened their doors and invited the community to contribute, so I found it odd that people were asked to change their plugin prefixes as it clearly looked like a distancing mechanism.  The equivalent of saying, “we’re really glad you felt the urge to contribute, but your code isn’t exactly up to scratch.”

I remember some discussion a while ago about a Symfony Forge for plugins, but this appears to have fallen by the wayside.  There definitely needs to be a review of the plugin hierarchy, perhaps bringing it inline with PEAR’s own directory-based naming structure.  Looking at the names alone, I’m stumped as to what certain plugins actually do!

The advent of 1.1 has brought about a significant change to the way in which plugins are related to each other, i.e. dependencies described in the package metadata. This is a fantastic step forward!!  Alas, my own plugins have no real dependencies therefore I am unable to put this new feature to the test but the concept alone makes it worthy of mention and a smattering of praise.

Mr Zaninotto calls it a day..

For those who don’t already know, François has announced his retirement from the Symfony project team, citing differences of opinion and his exclusion from core design decisions. This is a massive blow to the project, as the documentation he wrote for the framework was the main reason it became so successful.

I left a comment suggesting that he should take over ownership of the 1.0 branch, but I get the impression from his posting that he’s pretty fed up so I wouldn’t be surprised if he withdrew from the Symfony community completely. I do hope he sticks around, however..

A sad day for Symfonians everywhere! :-(

Virtualisation: A Symfony Developer’s Best Friend - Part 5

Hello! The good news is that we’re almost there. I hope you’ve been able to follow my instructions thus far - believe me, the end result is more than worth it. In this part of the tutorial, we will be dealing with the installation of both PEAR and Symfony, as well as the initial setup of a Symfony project. Go ahead, power up your VM and log into your shell account so we can get things started.

PEAR - Installation

  • Type ‘cd /usr/ports/devel/pear/‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter
  • After installation has concluded, log out/in to see the PEAR binary in your path
  • Type ‘pear channel-update pear.php.net‘ and hit Enter
  • Type ‘pear upgrade-all‘ and hit Enter

Symfony is installed the same way as a regular PEAR package. Easy peasy!

Symfony - Installation

  • Type ‘pear channel-discover pear.symfony-project.com‘ and hit Enter
  • Type ‘pear install symfony/symfony‘ and hit Enter
  • Log out and in to see the Symfony binary in your path

Symfony - Project Setup

  • Type ‘mkdir /var/websites/yourdomain.com/www‘ and hit Enter
  • Type ‘cd /var/websites/yourdomain.com/www‘ and hit Enter
  • Type ‘symfony init-project www‘ and hit Enter
  • Type ‘symfony init-app frontend‘ and hit Enter
  • Type ‘symfony init-app backend‘ and hit Enter
  • Type ‘symfony init-module frontend home‘ and hit Enter
  • Fire up your host O/S’s web browser and navigate to your VM’s IP
  • If you see a Symfony default success page, you’re done!

Congrats! You now have a virtualised web development platform! There’s not much else to say, really, although I will be covering the installation and configuration of additional tools that will further enhance your development experience. As far as your brand-new Symfony project is concerned, I’ll stop there and leave the rest to the framework’s superb documentation.

Symfony 1.0.15 Released

See: http://www.symfony-project.org/blog/2008/05/09/symfony-1-0-15-is-out

After the release of PHP 5.2.6 here is symfony 1.0.15. This revision fixes a regression in php5.2.6 and we do recommend you to upgrade if you plan to upgrade your PHP. Symfony 1.1 is not impacted by this problem.

Nice turnaround by the Symfony devs! Makes you wonder about the PHP team’s quality control, though..

Symfony 1.1: Should I be worried?

I read Francois’ most recent view on Symfony’s verbosity and was surprised at his dissent given his core involvement with the project. I can definitely see where he is coming from, as it can’t be easy to write easy-to-digest documentation for such a complex beast. I’m wondering if it is worthwhile upgrading as I’m quite happy with the framework as it stands - don’t get me wrong, the new form subframework is definitely a step in the right direction, but I don’t really like straying far from my metaphorical “comfort zone”.

Decent documentation would go a long way to convince me that a version switch is a good idea, but I don’t think I will find much reassurance if the next version of the book looks like a glorified API manual. I do hope that appropriate features and improvements from the 1.1 branch are merged across to 1.0, not just important security patches. I also hope we won’t end up with a split in the community as a result of the aforementioned blog post..

Virtualisation: A Symfony Developer’s Best Friend - Part 4

As promised, this post will detail the steps required in order to setup the various daemons on your VM. First of all, let’s improve your shell experience by installing OpenSSH - all that Ctrl-Alt focus switching nonsense that you’ve so far been exposed to is no use to man nor beast; we need a flexible solution so we can switch windows via Alt-TAB. Go ahead and log into your VM as ‘root‘ and we’ll get started.

OpenSSH Installation and Configuration

  • Type ‘cd /usr/ports/security/openssh-portable/‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter
  • Accept defaults on configuration screen, highlight ‘OK‘ and hit Enter
  • After the port has been installed, type ‘nano /usr/local/etc/ssh/sshd_config‘ and hit Enter
  • Scroll down to the line that reads ‘#PasswordAuthentication no‘, uncomment it and change to ‘PasswordAuthentication yes‘, then hit Ctrl-X to save the file
  • Type ‘nano /etc/rc.conf‘ and add ‘openssh_enable=”YES”‘ to the bottom of the file, then hit Ctrl-X to save the file

You can now manually start the SSHD process by typing ‘/usr/local/etc/rc.d/openssh start‘ and hitting Enter, or you can reboot your VM with the ‘shutdown -r now‘ command. Go ahead and manually start the daemon. To verify, download a copy of PuTTy (an excellent free SSH client), point it at your VM’s IP address - you can find this by issuing the command ‘ifconfig -a‘ from within your VM (look for the ‘le0‘ entry) - and try to connect. If you are presented with a dialog box asking if you wish to accept the server’s host key, you’re all set! Click ‘Yes‘ and try logging in as the user you created in the second part of this tutorial series. With any luck, you will be presented with a shell prompt. Kiss goodbye to that clunky VMware Server interface window!

If you tried to log in as ‘root‘, you’ll probably have noticed that you are getting “Access Denied” messages despite entering the correct credentials. Don’t worry, this is an inherent security feature of FreeBSD - you can only log in as a regular user. Once inside, however, you can become superuser by issuing the ‘su‘ command and entering the correct password. Before you can do that, however, you will have to give your own user account permission to do so.

  • Log into your VM as ‘root‘ (the old fashioned ‘VMware Server’ way)
  • Type ‘nano /etc/group‘ and hit Enter
  • Look for the line that reads ‘wheel:*:0:root‘, add a comma then your own username at the end - i.e. ‘wheel:*:0:root,jbloggs
  • Hit Ctrl-X to save the file and quit the text editor

Apache 2.2 Configuration

Now that we’ve made your shell a bit easier to work with, it is time to turn our attention to your web server software. Apache is an industry-standard and is a doddle to set up, once you get your head round the basics.

  • Log into your shell account and change to superuser via ‘su -
  • Type ‘nano /usr/local/etc/apache22/httpd.conf‘ and hit Enter
  • Edit the file so it looks like this - please note, I have cut out all of the inline comments and many of the irrelevant directives
  • Hit Ctrl-X to save and quit the text editor
  • Type ‘nano /usr/local/etc/apache22/extra/httpd-vhosts.conf‘ and hit Enter
  • Edit the file so it looks like this - obviously, you would swap out the placeholder directory with your own
  • Hit Ctrl-X to save and quit the text editor

With the configuration taken care of, it is time to add Apache to your VM’s startup procedure.

  • Type ‘nano /etc/rc.conf‘ and hit Enter
  • Add ‘apache22_enable=”YES”‘ to the bottom of the file
  • Hit Ctrl-X to save and quit
  • To manually start the daemon, type ‘/usr/local/etc/rc.d/apache22 start‘ and hit Enter

MySQL Configuration

Thankfully, setting up the MySQLd process is a lot more straightforward!

  • Type ‘nano /etc/rc.conf‘ and hit Enter
  • Add ‘mysql_enable=”YES”‘ to the bottom of the file
  • Hit Ctrl-X to save and quit
  • To manually start the daemon, type ‘/usr/local/etc/rc.d/mysql-server start‘ and hit Enter

Okay, I think that’s enough for now! You have successfully cranked up both your database and webserver, so next time will will focus on setting up Symfony. Thanks for reading!

Relocation, relocation, relocation..

I’ve moved this blog across to one.com hosting, as I am still staring at my screen in complete disbelief at Wordpress’ staff and their inability to give me a sound, justified reason as to why they don’t allow users to upload .txt files via their admin suite. The phrase “security risk” was volleyed back at me on the two occasions I contacted the support team. Eh?! All I wanted to do was upload configuration files to support my FreeBSD VM tutorial pieces!

Anywho, I had to pick a new theme because it turns out the one I picked was for Wordpress-hosted blogs only and I’m too busy to reverse engineer. The contrast should be a bit better, as black-on-white is more retina-friendly than vice versa.

The good news is that Part 4 of the tutorial is nearly ready and should be up in the next day or so.

Virtualisation: A Symfony Developer’s Best Friend - Part 3

Now that we’ve dealt with some basic user and directory management, it is time to get cracking and fill our delicious VM with quality web development software. First of all, however, we need to setup networking in order to access the internet. Our VM has been configured to use bridged networking - I’m working on the assumption that you get online via a broadband router (be it ADSL or cable) and that said router is capable of mapping ports between your external interface and your internal network interfaces. Personally, I use a D-Link cable router which, despite its shonky web admin suite, is pretty darn reliable and easy to maintain.

FreeBSD’s configuration utility is called sysinstall, which we will use in order to configure networking. Interaction is controlled via your keyboard - as with Windows, TAB will cycle through available fields and buttons. On with the show!

  • Log into your VM as ‘root
  • Type ‘sysinstall‘ and hit Enter to fire up the configuration utility
  • Select ‘Configure‘, then ‘Networking‘, and then ‘Interfaces
  • Select “le0” from the adapter list
  • When prompted if you want to configure IPV6, highlight ‘NO‘ and hit Enter
  • When prompted if you want to configure DHCP, highlight ‘YES‘ and hit Enter
  • FreeBSD will poll for an available DHCP server. If it is successful, enter a suitable hostname and domain in the relevant fields (they don’t have to resolve externally), then select ‘OK‘ and hit Enter
  • Choose ‘Exit‘ twice and then finally ‘Exit Install
  • To test your changes, try pinging Google!

If the test works, give yourself a small pat on the back and go make a cuppa. If it doesn’t or you don’t have the requisite hardware configuration, don’t panic! You can shutdown your VM with the command ‘shutdown -h now‘ and change the networking type to NAT. Go through the same procedure as before, searching for an available DHCP server (which VMware emulates) and setting up your hostname and domain information. The only drawback is that port forwarding won’t be as easy, if your intention is to allow testers/friends to try out your funky web applications over the web. I will attempt to cover this alternative setup method at a later date, so don’t feel left out! Stay tuned and I promise I’ll get you sorted!

Okay, those of you with cuppas should settle back down again and prepare to retrieve and install the latest build of the FreeBSD ports collection. Ports are installed via source tarballs, which are downloaded automatically from the internet when you invoke a port’s build command. For those of you familiar with C compilation, you will probably recognise some of the terminology used below.

Firstly, we want to grab the latest ports collection. Portsnap is just the command for the job - it is installed by default, so you won’t end up in a paradoxical situation like users of FreeBSD 6 or earlier who had to somehow install portsnap via the ports collection, despite the fact that they hadn’t yet installed their ports collection..

  • Type ‘portsnap fetch extract‘ and hit Enter

If I were you, I’d either go and grab a few biscuits to go with that cuppa (if you haven’t drank it all, that is) as the fetching and extraction process takes about 10 minutes. You can sit and watch it run it’s course if you really want to, but you will be treated to a monochrome poor man’s equivalent of the Matrix without the reference to spoons or white rabbits.. I recommend that you do something more interesting instead!

To install a port for the first time, you need to move into the port’s directory and build it by invoking the ‘make‘ command. Before we install any web development ports, we want to install one that will make our collective lives easier regarding port maintenance. Enter ‘portmanager’…

  • Type ‘cd /usr/ports/ports-mgmt/portmanager‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter
  • When the configuration screen appears, accept the defaults, select ‘OK‘ and hit Enter
  • Once installed, log out of your VM and then log back in - FreeBSD pathing means that you won’t actually be able to see the portmanager binary until you do so (if anyone knows a more efficient way to do this, please let me know!)
  • After you log back in, type ‘portmanager -ui -u‘ and hit Enter - this will run portmanager in interactive mode using the default bundled configuration options
  • A list of installed ports will slowly scroll down your screen, afterwhich you will be presented with your first update prompt
  • Press ‘Y‘ to update each port in turn or press ‘A‘ to update all out-of-date ports
  • Accept defaults when prompted at any configuration screens

Excellent work! Your installed ports are now all up-to-date! Next up, we need to install a decent text editor for our local configuration changes. Many people swear by VI/VIM but I prefer Nano - a cute redux of Pico, which came bundled with the archaic Pine UNIX mail client. Nano is really easy to use and even easier to build using the ports collection.

  • Type ‘cd /usr/ports/editors/nano‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter
  • Log out of your VM and log back in

Next up, we want to go ahead and setup Apache. The 2.2 branch is stable and perfect for our needs.

  • Type ‘cd /usr/ports/www/apache22/‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter
  • On the configuration screen, select ‘BDB‘, then highlight ‘OK‘ and hit Enter

PHP5 is next on the list! You see how easy this is? :-)

  • Type ‘cd /usr/ports/lang/php5/‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter
  • On the port’s configuration screen, make sure the APACHE option is selected - we want to build PHP5 as a Apache module. Highlight ‘OK‘ and hit Enter

You may have noticed that only the standard PHP5 extensions were installed. That is because the rest of them are stored in a handy meta-port, meaning we can add and remove extensions as and when we need to.

  • Type ‘cd /usr/ports/lang/php5-extensions/‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter
  • On the port configuration screen, select the following extensions:
    • ctype, curl, dom, filter, ftp, hash, iconv, json, mysql, mysqli, pcre, pdo, pdo_sqlite, posix, pspell, session, simplexml, soap, sockets, spl, sqlite, tidy, tokenizer, xml, xmlreader, xmlwriter, zip, zlib
  • Highlight ‘OK‘ and hit Enter

As you have selected the mysql extension, port dependencies will kick in and automatically install the MySQL 5.0 client plus library files - handy! The whole PHP extension installation process will take a while so be patient!

As we have installed the client, it would make sense to install the matching server port!

  • Type ‘cd /usr/ports/databases/mysql50-server/‘ and hit Enter
  • Type ‘make install clean‘ and hit Enter

If you’ve made it this far, then you’re doing great. You have installed the latest ports collection; you have updated your installed ports to the latest version; and you have successfully installed PHP5, Apache 2.2, MySQL 5.0 and a humble text editor called Nano. In my next post, I will show you how to configure each one in turn and add them to your VM’s startup procedure. TTFN!

Virtualisation: A Symfony Developer’s Best Friend - Part 2

In my previous post, I talked about setting up your development environment using VMware Server and a pre-built FreeBSD 7.0 VM. Today, I’ll be showing you a few easy configuration tweaks as well as my own “best practice” with regards to directory layout and user management.

Performance Tweaks

If you have an AMD multi-core processor, you may have noticed that your VM’s system clock ticks rather slowly. A number of VMware users picked up on this, blogged about it but didn’t seem to get anywhere initially. VMware themselves, in fact, we’re that helpful. It took me a fair bit of blog comment digging to arrive at a partial solution for this irritating little quirk! Enough waffle, here’s the fix:

  • Log into your VM as ‘root‘ with the password ‘thoughtpolice‘ (unless you changed it!)
  • Type nano /boot/loader.conf and hit Enter*
  • Drop in the following line:
    • hint.apic.0.disabled=1
  • Hit Ctrl-X to save and exit
  • Issue the command shutdown -r now to reboot your VM
  • You’re done!

* I should point out that ‘nano’ is a text editor that ISN’T installed by default, so I may have jumped the gun a bit. You can install it using the ports collection, which I intend to go into detail about in my next post. Therefore, it would probably be a good idea to skip this configuration tweak and come back to it once I’ve shown you how to install and maintain the software for your VM distro of FreeBSD. Cue mild facepalming! :-)
I say “partial solution” because you will notice timestamp slippage over a protracted period of time, but I guess it isn’t that much of a big deal if don’t keep the VM running 24/7. As we’re setting up a development environment, uptime isn’t the most crucial factor.

Directory Layout

One thing that a development server needs is a good directory layout. You want to be able to find projects quickly without the need for extensive grepping and searching. My own personal preference all revolves around the /var directory - don’t ask me why, it just does! For the sake of this example, let’s say we are going to be building a website for “Acme Computers“, using the domain ‘acmecomputers.com‘. Here is how I would go about the initial setup of my fangled development directory structure for such a website. Please note that we won’t be filling the directories with anything at this point in time; I will cover this in subsequent posts. Okay, here goes:

  • Log into your VM as ‘root
  • First of all, we want to create the directories where the actual website code will reside. Type the following commands, hitting Enter after each:
    • mkdir /var/websites/
    • mkdir /var/websites/acmecomputers.com/
    • mkdir /var/websites/acmecomputers.com/www/
  • Next up, we want to setup a version control directory structure for our new project. Again, we want to stick to the same conventions as before. Type the following commands, hitting Enter after each:
    • mkdir /var/repos/
    • mkdir /var/repos/acmecomputers.com/
    • mkdir /var/repos/acmecomputers.com/www/
  • Finally, we want to setup an area where we can store Trac installations - for those who don’t know, Trac is project management and ticketing webapp written in Python that hooks into various repository formats to offer an integrated view of a project’s lifecycle. No, I didn’t copy and paste that - I’m pretty sure I was in marketing in a former life.. Type the following commands, hitting Enter after each:
    • mkdir /var/trac/
    • mkdir /var/trac/acmecomputers.com/
    • mkdir /var/trac/acmecomputers.com/www/
  • You’re done!

Really not that much to it, to be honest. The format is always…

  • /var/<area>/<domain>/<subdomain>

… as I found it to be the most intuitive. YMMV, of course, but this system just makes sense to me.

User Management

First rule of UNIX - don’t do things as ‘root‘ unless you really, really have to. Second rule of UNIX - pay attention to the first rule. Your trusty VM does not come bundled with any user accounts, so you will need to make some! Fortunately, the process is a breeze - for this example, we will create a user account called ‘jbloggs‘ with a randomly-generated password.

  • Log into your VM as ‘root
  • Type the following commands, hitting Enter after each. Whenever you see <default>, just hit Enter without typing anything:
    • adduser
    • Username: jbloggs
    • Full name: Joe Bloggs
    • Uid: <default>
    • Login group: <default>
    • Login group is jbloggs. Invite jbloggs into other groups?: <default>
    • Login class: <default>
    • Shell: bash
    • Home directory: <default>
    • Use password-based authentication?: <default>
    • Use an empty password?: <default>
    • Use a random password?: YES
    • Lock the account after creation?: <default>
    • You will see something similar to the following confirmation text:
      • Username: jbloggs
      • Password: <random>
      • Full Name: Joe Bloggs
      • Uid: 1003
      • Class:
      • Groups: jbloggs
      • Home: /home/jbloggs
      • Shell: /usr/local/bin/bash
      • Locked: no
    • OK?: YES
    • You will see something similar to the following final confirmation text:
      • adduser: INFO: Successfully added (jbloggs) to the user database.
      • adduser: INFO: Password for (jbloggs) is: dvq8724.828
    • Remember and write this password information down!
    • Add another user?: NO
    • You’re done!

Finally, you will want to change the permissions on the directory structures you just created so that your new user is able to read and write to them.

  • As ‘root‘, type the following commands, hitting Enter after each:
    • chown -R jbloggs:jbloggs /var/websites/
    • chown -R jbloggs:jbloggs /var/repos/
    • chown -R jbloggs:jbloggs /var/trac/

We will play around with these permissions once we have set up the Apache webserver and all the delicious web development trimmings. This, and more, will be covered in my next post. Ta-ta for now!

Virtualisation: A Symfony Developer’s Best Friend - Part 1

At any given time, I have about 3-4 web app ideas floating around in my cranium. I like to test theories, assemble rough prototypes and basically braindump onto some virtual “paper”. My development platform of choice is FreeBSD, which I have used consistently for the past 10 years. I’m command-line through and through, baby, so you better get used to it! I like using Windows, but not as a development environment, and I believe I don’t look metrosexual enough to own a Mac (I lack the sweaters and “sports-casual” look).

Unfortunately, renting a FreeBSD box isn’t the most cost-effective option as a testbed for Symfony doodling, which brings me to the crux of this article. Wouldn’t it be wonderful if I could mix the pointy-clickyness of Windows with the stability and flexibility of FreeBSD?

Well, dear reader, you can. VMware Server is not only your friend, it is your saviour. Allow me to park this rambling narrative for a few moments in favour of a website quote:

“Begin enjoying the benefits of server virtualization with the free VMware Server. VMware Server installs on any existing server hardware and partitions a physical server into multiple virtual machines by abstracting processor, memory, storage and networking resources, giving you greater hardware utilization and flexibility. Streamline software development and testing and simplify server provisioning as you utilize the ability to “build once, deploy many times.”

Free!! That’s the best price!! Okay, now we’ve established our base, we need to find a way of smothering it with a layer of hot, melted FreeBSD. We could create a virtual machine from scratch using the FreeBSD ISOs, but wouldn’t it be nice if we could somehow source a pre-built bundle replete with .vmx configuration file? Thankfully, you can grab the latest VMs from the lovely people over at Thoughtpolice - the latest build of FreeBSD that they cater for is 7.0 and they even give you a whizz-bang guide on how to get up and running in less than a minute. Here’s a nice bulleted list for those who hate extracting information from meandering commentary:

  • Download and install the latest version of VMware Server from the VMware website
  • Download the FreeBSD VM via BitTorrent, and extract the archive to a sensible location on your PC
  • Read the “FreeBSD 7.0 in 1 minute” guide
  • Run VMware Server Console, select “Local host” and click “OK
  • Click on “Open Existing Virtual Machine
  • Navigate to the place you saved your VM, then open the “freebsd-7.0-i386.vmx” file
  • You will see a breakdown of the resources available to your VM, so adjust them accordingly. I can recommend the following settings, if your PC is fairly recent and has >2GB RAM available:
    • Memory: 384MB (more than enough, but I like the number)
    • Ethernet: Bridged (I have a cable router, so I bridge onto the network in order to map ports between my internal LAN and my external interface - if you have problems doing this, select NAT)
    • Processors: 1 (if you have a multi-core processor, you will run into some mild TSC/timestamp issues initially despite only specifying a single processor here - I will show you how to fix this later on)
    • Leave everything else as default!
  • When you’re happy, click “Start this virtual machine” - you will be prompted to create a new UUID, so select “Create” and click “OK
  • Your VM will start up - cue lots of scrolling jargon that you don’t really need to pay attention to!
  • You will eventually arrive at a “login:” prompt - congratulations, you made it!
  • Log in as “root” using the password “thoughtpolice
  • This is as far as we want to go just now, so issue the command “shutdown -h now” in order to shutdown your VM - wait for confirmation that it is safe to power off, then do so by clicking the big red STOP button in the toolbar at the top of your VM’s window
  • You will be taken back to the VM information screen - close down the application, in your own time of course
  • You’re done! Well, for the time being at least

That was easy, wasn’t it? Believe me, we’ve only just scratched the surface! Stay tuned for the next installment.