Samisa has written a nice post about using PHP in the enterprise. A commenter there argues that he don’t use PHP because it’s a dynamically typed language. It’s somewhat true that if you’re coming from a statically typed language background you’re stormed with so many questions and wonder possible nightmares of using one. Once you start learning a language and understand how programs are suppose to be written in that language most of these problems go away.
For all these years, it has only been Java/.Net programmers who has been enjoying the luxury of service oriented architectures. These folks understand the value of building a business functionality as a service or exposing an existing functionality as a service. PHP programmers have been building their web based programs happily without having to know what services mean. People in the PHP community has tried to bring Web services into the language with varying degrees of success. These are very courages and thoughtful efforts. But if you analyze them objectively you’ll see that many of these libraries doesn’t contain that much of features in order to build/integrate an application with an existing enterprise app.
What WSF/PHP has done is lower the bar of building PHP applications that can fit with existing applications in an enterprise written in Java/.Net or whatever the language that might be. Also, it has enabled ability to integrate existing PHP applications to your other enterprise applications.
One strong reason companies have embraced developing applications in Java is that so their data will not be isolated from rest of the enterprise data. In the past having a PHP application inside your company might have been frowned upon because it doesn’t make sense to have information which is isolated from all the other applications in the company. This is why most organizations invest in an ERP for example. But now, this has become a non issue. If you’re using open standards inside your enterprise to communicate/integrate applications, using WSF/PHP, you can integrate or extend services seamlessly with rest of your enterprise services.
Among the large number of WAMPs on the net there’s room for yet another one. SOAWAMP. This one’s sole purpose is to bundle WSF/PHP together and provide a platform for developing Web services right out of the box. So you don’t have to go through the README and install WSF/PHP on your Windows machines. In fact, you don’t have to install anything. This is all thanks to the excellent work of The Uniform Server team.
If you have been reading on the web how bulky and complex it is to develop WS-* applications, and how complex it is to get features like WS-Security, MTOM etc… download SOAWAMP and run the samples related to those sections and see, go through the source and see for yourself how simple the API is. As for all the other folks who still blather without looking … Feh.
SOAWAMP is a combination of The Uniform Server and WSF/PHP. The latest release of SOAWAMP bundles the most recent version of WSF/PHP. Download. Unpack. Double click. Have fun!
Doing stupid repetitive work for extended periods of time can cause serious drain bammage. Coming up with a static HTML page for WSF/PHP samples is just tedious work. If you’re like me, you use Emacs for everything you do including HTML editing. I was trying to create a page which listed all the samples. You could view the code as well as run it once you install WSF/PHP. The default was a standard directory listing by the web server. Trying to write a static HTML page with Emacs for that many samples is madness. Luckily with very few lines of Ruby, stupid repetitive work can be a source of fun.
A table listing a link to the script and showing the code would be nice. I could write a table in Emacs but filling it with content for all the samples is the problem.
<tr> <td> <a href="script_name.php">script name</a> <div> <code> code here </code> </div> </td> </tr>
Oh, I need to get a description up there as well. The README.SAMPLES file that’s in the samples folder has a description for each sample. Great, I could use that. Let’s throw some Javascript goodness with my favourite light weight JS framework mootools as well. It’s really easy to generate that for all the samples. Prettify was used to get the syntax highlighting. I did tried the syntaxhighlighter but after combining with moo the page got messy when the slide up happens. Anyways, FWIW, here’s the no brainer Ruby code.
#!/usr/bin/env ruby require 'cgi' lineno = 1 desc_row =<<E <tr class="%s"> <td class="desc">%s</td> </tr> E code_row =<<E <tr class="%s"> <td> <a href="%s">%s</a> (<a href="#" id="%s">show code</a>)<br /> <div id="%s"><br /> <pre class="prettyprint"> %s < /pre><br /> </div> </td> </tr> E js =<<E var %s = new Fx.Slide('%s'); %s.hide() $('%s').addEvent('click', function(e) { e = new Event(e); %s.toggle(); e.stop(); }); E File.open('README.SAMPLES', 'r').each do |line| if line =~ /^([a-z].*\.php)/ then (filename, description) = line.split(/[ \t]+-[ \t]+/) php_code = (File.open(filename.strip, 'r').readlines.collect do |l| CGI.escapeHTML(l) end).join.gsub(/\r/, '') row_state = ((lineno % 2) == 0) ? "even" : "odd" run_link = (filename.strip =~ /client/) ? "Run client" : "WSDL" class_toggle = "toggle-#{filename.strip.gsub(/.php/, '').gsub(/\//, '-').gsub(/_/, '-')}" class_code = "code-#{filename.strip.gsub(/.php/, '').gsub(/\//, '-').gsub(/_/, '-')}" js_var = "#{filename.strip.gsub(/.php/, '').gsub(/\//, '').gsub(/_/, '')}" if ARGV[0] == "-html" then printf(desc_row, row_state, description) printf(code_row, row_state, filename.strip, run_link, class_toggle, class_code, php_code) elsif ARGV[0] == "-js" then printf(js, js_var, class_code, js_var, class_toggle, js_var) end lineno += 1 end end
Had to do a bit of copying and pasting here and there and the page was done.