Wednesday, 31 August 2011

Drupal 5 and CKEditor

FCKEditor has had its hey days, worked well with drupal as well, but it was bloated and slow. Then came the CKEditor, shiny new and fast gui editor. There is a drupal 6 & 7 module for CKeditor, but the module for drupal 5 is missing.

Understandaby, we dont want no one to use drupal 5 any more... however there are still some legacy systems using drupal 5, like the one i am currently working on. upgrading to drupal 6 is not straight forward and requires approvals and budgets from tons of people.

The next obvious option is to write a custom quick fix to make drupal 5 work with ckeditor, ckeditor and drupal 5 works out of the box with wyiwyg module but unfortunately only works on drupal defined or cck defined content types, if the content type is defined programatically - it doesnt work with those textareas.

Hence a need for a custom module like the ones available for drupal 5 & 6. There may be a work around i am thinking but havent yet got time to get around to trying. I plan to use hook_form_alter() to insert a filter element on the forms and try to get ckeditor work like that. May be people have tried this earlier and it is working, but a google search did not find any thing promising.

I do not have a capacity to currently write a contributed module for ckeditor, but would like a quick fix. Will post later it i am successful.

Saturday, 27 August 2011

Preparing your drupal development environment with Mac OS X Lion.

I just got a MacbookPro and the first thing i wanted to do was get a drupal developer environment on the machine, I ideally would have like to mirror what i had on my windows laptop - which was Apache/PHP/MySQL/Eclipse.

I googled and found OSX Lion comes with Apache and PHP built in, I must add here that i didn't know there was a MAMP server similar to the WAMP server i had installed on my windows machine, but using the already installed Apache and PHP was just as easy.

To enable Apache just do the following:

1. Go to System Preferences 
2. Click sharing
3. Click Web Sharing service
4. Note the location of the Website Folder on my macbook pro it was Macintosh HD->Library->WebServer->Documents, i would think this is the same for you as well.

We can change the document root from httpd.conf if required, i left it as is.

A quick run to safari/firefox and go to http://localhost to make sure Apache is working - and it does tell you emphatically 'It Works!', note PHP is not yet enabled and we will have to enable that form the apache configuration file.

Enable PHP (you may have to use root privs or sudo to do this)

1. open terminal window
2. sudo cd /private/etc/apache2
3. sudo vi httpd.conf
4. in vi search for string php5_module by typing /php5_module
5. switch to edit/insert mode by typing 'i'
6. remove the '#' and save the file by typing ':wq'
7. disable websharing (System Pref->sharing->web sharing) and re-enable.

Create a php file with phpinfo() and checking on the browser confirms php is working with Apache.

MySQL is not preinstalled on the mac osx so this requires to be downloaded from www.mysql.com - i installed the mysql 5.5.15. Downloading the "dmg" file and clicking when complete opens the disk image revealing  two .pkg files. the first mysql-5.5.15-osx10.6-x86.pkg will guide you through the installation, on completion you need to click the MySQLStartupitem.pkg to make sure mysql comes up when your macbook is restarted. I also suggest installing the MySQL pref pane, to allow you to manage mysql better.

There i just one more thing you will have to do to ensure mysql works with PHP by pointing php to the right mysq.sock file, i got this done by looking at the place MySQL was installed and did the following

sudo mkdir /var/mysql
sudo ln -s <current localtion of mysql.sock> /var/mysql/mysql.sock

Install MySQL GUI tools to administer mysql and MySQL query browser, this will be required for drupal development.

After installation restart your macbook pro and confirm mysql is up and working by using the mysql query browser, create a database and you are now ready to install drupal.

Download the latest drupal 7.7 and place in the documents folder and follow drupal installation steps as normal, note you will require to change permissions on the sites/all folder to change the settings.php and also install files folder. I skipped the step and changed the owner of the Documents folder to the one i will be using most.

sudo chown 'myuser' /Library/WebServer/Documents

I have installed eclipse pdt from 'pdt-1.0.3.R20080603_debugger-5.2.14.v20080602-all-in-one-macosx-carbon.tar' and placed the eclipse folder in applications.

The next step is of course editing preferences to make sure drupal files like .install, .module are added to php content type and tabs are converted to spaces as per drupal coding standards.

the PDT has zend debugger preconfigured which is a great thing for serious development. Hope you find this helpful, next steps is configuring drush and you are all through!

Sunday, 14 August 2011

Should i buy a Macbook?

I tend to admire each apple product when it arrives, for their design and astethic sense. The ipad2 or macbook pro or the thinner macbook air - apple just seem to bring up one lovely product after another. The techie kid inside me wants to desperately own a macbook.

Every few days i have an itch to buy a macbook pro or a macbook air for my drupal/php development, I must add I started as a windows fan and used to scoff at apple afficionados, and felt apple owners are a bunch of kids bragging about their toys while apple goes to the bank laughing. Well not a lot has changed about how i feel about Apple as a marketing company.

For instance if you look at the current offerings for macbook pro, we have a core2duo, i5 & i7 processors. As far as core2duo goes, this is a 4 year old processor and at that it is selling at around £984 Core2Duo Macbook Pro on Amazon.co.uk whereas I had bought a core2duo based windows laptop approximately 3 years ago at £500 pounds looks like this macbook is overcharged.

i5 & i7 macbooks are available but cost much more than windows counter parts, atleast by over 300-400 pounds, for example the sony viao laptop with i5 is costing around £619 but a similar spec Apple Macbook Pro is available for £887.90 while the apple store sells it for £999 this is a good 300 pounds for a premium to own a apple.

The general consensus is Apple build quaility and stuff that goes into make the macbooks are different and better quality products, well maybe not quite. since apple started using intel processors these have changed and there is not a lot of diference in how both type of laptops are made. they use the same processor, memory, hdd, usb etc albeit the graphics may be a tad better but you can get windows laptops with similar graphics options and the would still be atleast 200 pounds cheaper.

The other argument is most of the stuff you require to work with is already included in a mac. Well again you will have to pay for ms office if you want for mac, outlook for mac, photoshop if you work with graphics etc. so may be the argument doesnt hold true yet.

It is not like 'I like a ferrari but cannot afford it' but i am still struggling with my logical mind should i make a plunge and buy an overpriced good looking laptop? my mind keeps telling me no for now.

I know this is just not a windows laptop wrapped in tin foil with a picture of a fruit on the lid. There is the OS X factor and other small tid bits that make working on a Apple macbook worthwhile but i am not yet ready to pay a premium of 300 pounds on that yet.

Add behat in Symfony 4

To add behat in Symfony 4 i have generally followed this link https://blog.rafalmuszynski.pl/how-to-configure-behat-with-symfony-4/ How...