Visit To PHP London

Last night I had the opportunity to speak at the PHP London group, giving a talk entitled “PHP Deployment with Subversion”. This is the talk I will be giving next week at the Dutch PHP Conference in Amsterdam, and giving the same talk last night was the last step in a whole series of preparation for next week. (The slides will be available after the Dutch conference)

As ever it was great to get to the event and meet the people there, I don’t make it to the PHP London meetings very often but I always have a good time when I do. Although this talk was supposed to be a “test drive” for next week, I was actually very squeaky happy to get the invite to speak! Anyway the guys there were great as usual, helping me get set up with the projector, providing a pep talk, and buying me a beer afterwards.

The talk itself went fine, nothing more and nothing less. It was perfect for time, which is excellent as I had absolutely no idea how long I would talk for. I was greatly helped by using Powerpoint (yes, I had to boot into windows, scary!) with its Presenter View which has a timer. This view also shows you your current slide, the notes for this slide, and the upcoming slides which is all good (so long as you can read very tiny writing from standing 4 feet away from your laptop – happily I’m long-sighted!). The content I think is OK – lots of questions came out after the talk which was really interesting, and I certainly realised there were a few points that I need to mention when I give the talk again. The slides perhaps leave something to be desired, colours look different projected and there was a particularly horrible shade of yellow which appears on quite a few slides – oops!

I had a great night and although I wouldn’t say I’m feeling confident for next week, I feel like there are fewer unknowns. I also came to terms with the idea that feeling terrible about a talk is just not something I’m going to get over until I have done the talk – its all part of the preparation I guess.

SugarCRM SOAP API Examples

By popular request, here are some examples that worked for me when using the SOAP API offered by SugarCRM. Its nice that there is an interface, but it isn’t brilliantly documented or nearly as widely used as it should be!

SugarCRM can’t talk to PHP 5 native SOAP libraries in WSDL mode, so connect without it. Find below a series of queries that each worked for me, all just dumped here in succession, don’t try to run this whole piece of code – it is intended as a series of examples. Use each line and then var_dump($response) to see what’s happening.

// set up options array
$options = array(
        "location" => 'http://192.168.1.129/aeat/spm/crm/soap.php',
        "uri" => 'http://www.sugarcrm.com/sugarcrm',
        "trace" => 1
        );
// connect to soap server
$client = new SoapClient(NULL, $options);

// look what modules sugar exposes
$response = $client->get_available_modules($session_id);

// look in more detail at the fields in the Accounts module
$response = $client->get_module_fields($session_id, 'Accounts');

// look for a particular account name and then get its ID
$response = $client->get_entry_list($session_id, 'Accounts', 'name like "%LornaJane%"');
$account_id = $response->entry_list[0]->id;

// create a new account record and grab its ID
$response = $client->set_entry($session_id, 'Accounts', array(
            array("name" => 'name', "value" => 'New Company')
            ));
$account_id = $response->id;

// create a new contact record, assigned to this account, and grab the contact ID
$response = $client->set_entry($session_id, 'Contacts', array(
            array("name" => 'first_name',"value" => 'Geek'),
            array("name" => 'last_name',"value" => 'Smith'),
            array("name" => 'email1',"value" => '[email protected]'),
            array("name" => 'account_id',"value" => $account_id)
            ));
$contact_id = $response->id;
    

I hope this helps – if you have anything to add, or would like to post some examples, please do :)

SugarCRM SOAP API

I don’t know when SugarCRM, the open source CRM tool, first acquired a SOAP API but I missed it completely. I’ve used SugarCRM a few times, on quite a casual level, and only fell across the SOAP API because I needed it.

The first thing to note is that the SOAP API for SugarCRM is advertised as being incompatible with the PHP 5 SOAP client implementation, and they recommend you use nusoap. However this isn’t true and I found it worked fine with PHP 5 in non-WSDL mode.

The second thing to note is that the documentation is rubbish. The best I could find is on their developer wiki and it isn’t enough to write an application with. I had to do a fair amount of fiddling around on the server side to understand when I was making mistakes which isn’t ideal for remote system calls! They do, however, have very good inline documentation so I ran PHPDocumentor over the file which had the stuff I was dealing with in it. I can’t find an equivalent online so you can see my copy over here

Also if you go to your own sugar installation and append /soap.php to the URL, you will see some information there about formats plus a link to the WSDL. The WSDL isn’t very human-readable but the top bit of it defines the custom data formats like “name_value_list” and shows you how to assemble them to submit to SOAP. If I can work out a good way of presenting that information I’ll add it somewhere and link to it.

There will also be a follow-up with the script that worked for me. If this helps, or you have any questions, then add a comment please :)

SugarCRM Custom Fields

‘Tis the week for code snippets it seems – actually its mostly that I’m working with SugarCRM in anger for the first time and falling into a few traps. Due to the unique way in which this product is funded, there is a lot less community support around than I’d expect for a product this size.

Today I attempted to create custom fields for the first time, which should have been much easier than it was. The first problem was that all the tutorials deal with earlier versions of Sugar and the interface has changed. The second problem was that I kept on getting lots of errors when I tried to create a custom field. The errors were Javascript errors but when I looked in my apache error log there were lots of these:

PHP Warning:  LanguageManager::include(cache/modules/ModuleBuilder/language/en_us.lang.php) [function.LanguageManager-include]: failed to open stream: No such file or directory in .../include/SugarObjects/LanguageManager.php on line 91, referer: ...
index.php?module=ModuleBuilder&action=index&type=studio

On closer inspection I realised the cache directory was empty. I made this writeable by the apache user and everything started working after that.

Custom Field Creation

Here’s a very quick run through on the steps that I followed. From the home screen, go into the admin section and then click on “Studio”. In the left-hand pane, expand the folder for the module you want to add things to and click on “Fields”. At this point you should read the help entries in the right hand screen but for the impatient: Click on “Add Field”, enter the field details and click on “Save”. The field name gets saved with a suffix of “_c” and should appear in the central pane under “custom”. If it doesn’t, see above for my comments about the cache directory.

The new field needs to be added to the layout before you will see it – this seems to fool a lot of people and I must admit I would have missed this myself if I hadn’t read it on the forums. Once you have created your field, go back to the tree view on the left and choose which layouts you’d like to be able to see your field in. Again there is help on the right hand panel but basically you drag the “new row” thing from the left hand column in the central panel to the right hand column in the central panel, and then drop your new field on top of it.

Hope this helps, its taken me quite a while to get to grips with what should be fairly simple. I’ll add a final note to say that the custom fields are available through the SOAP API – just remember their names get suffixed with a “_c”.

ZendCon Call For Papers

The ZendCon Call For Papers is now open. This conference is one of the biggest of the year but unfortunately is only held in the US. This year I am planning to submit talks for consideration for the first time … wish me luck :)

PHP London Meet and Some Heckling

I’ve been in London on business again this week (hopefully my wild travelling will calm down a bit now) which had the nice side-effect of allowing me to get to the PHP London meetup on Thursday. It was nice to see people that I met at the conference the previous week and also to meet some people who I hadn’t managed to catch up with previously.

The talk was from William Coleman of Microsoft talking about FastCGI and using PHP on Windows. He’d have done better to not say “We’re all guys here” in his opening remarks as I found myself heckling a speaker for the first time in my life!! I counted 4 women there out of 35 or so people, so a minority but a definitely existing one. He did apologise (about 17 times and after digging a bigger hole) and I had a brief chat with him later on, and gave him my phpwomen.org business card.

The talk was good and interesting, and he brought with him a remarkable sense of humour, which he probably needed since there were lots of smart comments coming from all angles. He did however impress upon us that performance of PHP on Windows is now comparable to performance of PHP on Linux, which was actually very interesting to know. Personally I have been staying away from PHP on Windows for 5 years or so but since I now work for Ibuildings who are Zend partners, then I guess I need to have more of a clue! Other than a few confusing moments where a comparison was made between running PHP on Windows against running it on Apache (what? Is Windows a web server now?) it was a good session and its nice to hear about these developments. My feeling is that no matter how stable PHP is on Windows, its the stability of Windows itself that means I’ll be avoiding it in my production servers for some time yet.

The punchline of the evening? Apparently microsoft have invented this great thing, called a shell, where you can just type comands in to your server rather than clicking on things, so you can manage servers remotely …

PHP London 2008

On Friday was this year’s PHP Conference in London and I must say it was a roaring success. The whole conference had completely gone up a gear from last year (the only other time I’ve attended) with a larger venue, choice of tracks, more attendees and better food.

I was there representing phpwomen.org with a stand and some t-shirts to give away as well as some information about the group. We took 30 t-shirts and they were all completely gone by lunchtime, which was a great response. Even after that the stand was buzzing all day with people dropping by to ask about the group and how to get involved/get more t-shirts/help us gain more recognition. I was surprised and pleased by the response of attendees, both male and female, I met so many interesting people that I can’t begin to list them here but it was great to chat to you all! Its great to be able to raise awareness at events like these and the phplondon committee were wonderfully supportive of us throughout the organisation phase and during the day itself.

My new employers, Ibuildings were sponsoring the event so I was also able to spend some time with my colleagues and meet some new ones. I also briefly rebranded to the distinctive red ibuildings shirts at one point, to look like part of the team while we took some photos. It was great to see the guys doing the Zend Platform demos and to be able to hang around with them – including the guys from the Netherlands who were there. Ivo Jansch (CTO over there) gave a talk which I enjoyed and was well received all round. I didn’t realise until then that I actually work in the tallest team ever! I’m one of the smallest – at 5’11” this is pretty unusual :)

Since I was doing so many other things on the day I didn’t get to a lot of the talks but what I did see was well-prepared and the audience were great, with some really interesting questions being asked in all the sessions I attended. There were two tracks, in rooms just across the corridor from one another, and the rooms were well-managed and ran smoothly throughout the day. The conference also provided a “recharge room” with juice for people and devices alike. The venue was great and was big enough for everyone without any crowding or bottlenecks.

All in all I’d like to congratulate the organisers on a great event – can’t wait for next year :)

Offline Geeking

I don’t spend a lot of time hanging around with geeks in the real world. I spend a lot of time hanging around with them in virtual spaces and some of the people I have met there are my closest friends. Offline meets are … quite different. Lots of geeks are quite shy, for starters. Some are quite egotistical, like the guy I met last year at the pre-conference social for phplondon and was horrified to hear that I create PHP using vim instead of a “proper IDE” and said how happy I was that I had made the effort to reach out to the conference and that he was sure I would learn a lot – the implication being that anyone who writes code with a keyboard is clearly a n00b. I’m hoping to avoid a repeat of that experience. I know I don’t look like a PHP developer but the friends I meet online can’t see that and I kind of forget … until an offline meet.

Perhaps experiences like these put me off doing the real-life thing but I am honestly so excited about PHPLondon tonight and tomorrow that I can’t imagine staying away. I’ll be promoting phpwomen at the main conference and I’m really excited about that too – look out for flocks of girls in bright purple t-shirts!

(OK, maybe not flocks…)

PHP London and Another Busy Week

I heard last week that the PHPLondon conference is completely sold out – I had a funny feeling it might be :) I will be there, this Friday 29th February and looking forward to a great event. I’ll be at the pre- and post-conference socials, if you are an online acquaintance please stop me and say hi – I should be easy to spot as I’m female, tall, and have curly hair, there aren’t a lot of us around! I would be very pleased to meet you anyway so do say hello.

PHPWomen.org will be represented there, we have information about the group plus some women you can talk to (whether you are a woman or not, we’re not discriminatory!). We will also be giving away a few t-shirts, we don’t have a lot though so do come and demand one if you want one.

Once again things are very busy this week as I am travelling on business so I won’t be online a lot. Only been back a few days and it would be an understatement to say that I’m tired but hopefully things won’t carry on at this rate forever. Anyway its Sunday which usually means I should be packing …