<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Minimizr.com &#187; PHP</title>
	<atom:link href="http://minimizr.com/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://minimizr.com</link>
	<description>More With Less</description>
	<lastBuildDate>Sat, 05 Jun 2010 21:29:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setup MAMP (Mac, Apache, MySQL And PHP) on Mac OS X 10.5 Leopard</title>
		<link>http://minimizr.com/blog/2007/10/setup-mamp-mac-apache-mysql-and-php-on-mac-os-x-105-leopard/</link>
		<comments>http://minimizr.com/blog/2007/10/setup-mamp-mac-apache-mysql-and-php-on-mac-os-x-105-leopard/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 13:39:14 +0000</pubDate>
		<dc:creator>kristian</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://www.minimizr.com/blog/2007/10/setup-mamp-mac-apache-mysql-and-php-on-mac-os-x-105-leopard/</guid>
		<description><![CDATA[New Mac OS X 10.5 Leopard comes with new versions of Apache and PHP (Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4), so it is quite easy to setup a MAMP server. Sure there are other ways to do the setup: You can build Apache, MySQL and PHP from sources, you can use MacPorts or you can [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>New Mac <a href="http://www.apple.com/macosx/leopard/">OS X 10.5 Leopard</a> comes with new versions of Apache and PHP (<code>Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4</code>), so it is quite easy to setup a <a href="http://en.wikipedia.org/wiki/MAMP">MAMP</a> server. Sure there are other ways to do the setup: You can build <a href="http://httpd.apache.org/">Apache</a>, <a href="http://dev.mysql.com/">MySQL</a> and <a href="http://www.php.net/">PHP</a> from sources, you can use <a href="http://www.macports.org/">MacPorts</a> or you can use pre-build packages like <a href="http://www.mamp.info/">MAMP</a> or <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a>. But in my opinion, because Apache and PHP are already installed, they are easy way to go and will minimize you work.</p>
<h2>Apache</h2>
<p>To enable pre-installed PHP, you have to edit httpd.conf file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>httpd.conf</pre></div></div>

<p>And uncomment next line:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">LoadModule</span> php5_module libexec/apache2/libphp5.so</pre></div></div>

<p>If you want to make other configuration changes, for example define virtual hosts, it&#8217;s better to use user&#8217;s configuration file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>users<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>username<span style="color: #7a0874; font-weight: bold;">&#93;</span>.conf</pre></div></div>

<p>After making changes, restart Apache aka Web Sharing. Go to System Preferences > Sharing and unselect and select again Web Sharing. That&#8217;s it. Now you have the Apache and PHP running. If there are any problems, you can examine the Apache error_log. Go to Console > /var/log > apache2 > error_log.</p>
<h2>PHP</h2>
<p>If you want to make changes to php.ini, do the following. Copy php.ini.default to php.ini:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini.default <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>And to make changes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">644</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">444</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>After making changes don&#8217;t forget to restart Apache.</p>
<h2>MySQL</h2>
<p>MySQL is a little trickier. It is not pre installed in OS X and in my opinion easiest way is to use binary from MySQL.com. So, <a href="http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg">download</a> the current version, which is mysql-5.0.45-osx10.4-i686.pkg at the moment and install it. Then install MySQLStartupItem.pkg and copy MySQL.prefPane to OSX/Library/PreferencePanes. It seems to be that current versions preference pane is not quite compatible with OS X 10.5. It shows if the server is running or stopped, but you can&#8217;t star or stop with it. MySQL starts when the OS starts, but you can start or stop it manually from console:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>StartupItems<span style="color: #000000; font-weight: bold;">/</span>MySQLCOM<span style="color: #000000; font-weight: bold;">/</span>MySQLCOM start
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>StartupItems<span style="color: #000000; font-weight: bold;">/</span>MySQLCOM<span style="color: #000000; font-weight: bold;">/</span>MySQLCOM stop</pre></div></div>

<p>MySQL with default settings use socket in /tmp and pre-installed PHP presumes it to be in /var/mysql, so you have to update the location in php.ini:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">mysql.default_socket <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> /tmp/mysql.sock</span></pre></div></div>

<p>Perhaps you could also use a symbolic link from /var/mysql/mysql.sock to tmp/mysql.soc. <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html">MySQL GUI Tools</a> are also working nicely with new OS X 10.5.</p>
<h2>Mac OS X 10.5</h2>
<p>No you should have a MAMP server running nicely. If you want to make host name changes &#8211; for example you can use different names for localhost to take advantage Apache&#8217;s virtual hosting &#8211; edit hosts file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://minimizr.com/blog/2007/10/setup-mamp-mac-apache-mysql-and-php-on-mac-os-x-105-leopard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Minimal Web Services with XFire, Spring and PHP</title>
		<link>http://minimizr.com/blog/2006/11/minimal-web-services-with-xfire-spring-and-php/</link>
		<comments>http://minimizr.com/blog/2006/11/minimal-web-services-with-xfire-spring-and-php/#comments</comments>
		<pubDate>Mon, 13 Nov 2006 19:27:17 +0000</pubDate>
		<dc:creator>kristian</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[XFire]]></category>

		<guid isPermaLink="false">http://www.minimizr.com/blog/2006/11/minimal-web-services-with-xfire-spring-and-php/</guid>
		<description><![CDATA[If you have a Java web application implemented with Java 5 and Spring Framework, it is really easy to expose your POJOs as web services. In this example I use XFire and JSR 181 annotations for that. I&#8217;ll also make a small web service client example with PHP. The goal is to add web services [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>If you have a Java web application implemented with Java 5 and <strong><a href="http://www.springframework.org/">Spring</a></strong> Framework, it is really easy to expose your POJOs as web services. In this example I use <strong><a href="http://xfire.codehouse.org/">XFire</a></strong> and JSR 181 annotations for that. I&#8217;ll also make a small web service client example with <strong><a href="http://www.php.net/">PHP</a></strong>. The goal is to add web services to the existing Java code with absolute minimal code addition. I was about to add web service authentication with Acegi Security, but instead for now, there is no authentication in this example.</p>
<p>XFire has a quite versatile but scarce <a href="http://xfire.codehaus.org/User%27s+Guide">user&#8217;s guide</a>. But it is a good start, so start with <a href="http://xfire.codehaus.org/Overview">overview</a> and quick start. Add XFire libraries and the depencies with the help of a <a href="http://xfire.codehaus.org/Dependency+Guide">Depency quide</a>. This example works at least with the following libraries:</p>
<table>
<tr>
<td valign="top">
<ul>
<li>xfire-all-1.2.2</li>
<li>activation-1.1</li>
<li>commons-codec-1.3</li>
<li>commons-httpclient-3.0</li>
<li>commons.logging-1.0.4</li>
<li>mail-1.4</li>
<li>jaxen-1.1-beta-9</li>
<li>jdom-1.0</li>
</ul>
</td>
<td valign="top">
<ul>
<li>junit-3.8.1</li>
<li>servlet-api-2.3</li>
<li>spring-2.0</li>
<li>stax-api-1.0.1</li>
<li>wsdl4j-1.5.2</li>
<li>xbean-spring-2.5</li>
<li>wstx-3.0.1</li>
<li>XmlSchema-1.1</li>
</ul>
</td>
<td valign="top">
<ul>
<li>xfire-jsr181-api-1.0-M1</li>
<li>jaxb-xjc-2.0.1</li>
<li>jaxb-impl-2.0.1</li>
<li>jaxb-api-2.0</li>
<li>aopalliance-1.0</li>
<li>commons-beanutils-1.7.0</li>
</ul>
</td>
</tr>
</table>
<p>XFire 1.2.2 package comes with xbean-spring-2.6. There can be some <a href="http://forum.springframework.org/showthread.php?t=29867">problems</a> with that version but at least version 2.5 is working with Spring 2.0.</p>
<p>First, add <strong>xfire-servlet.xml</strong> into WEB-INF directory. Here are the default settings from the user&#8217;s manual:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot;</span>
<span style="color: #00bbdd;">    &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&gt;</span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;import</span> <span style="color: #000066;">resource</span>=<span style="color: #ff0000;">&quot;classpath:org/codehaus/xfire/spring/xfire.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jaxbTypeMappingRegistry&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.codehaus.xfire.jaxb2.JaxbTypeRegistry&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">init-method</span>=<span style="color: #ff0000;">&quot;createDefaultMappings&quot;</span> <span style="color: #000066;">singleton</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;webAnnotations&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;handlerMapping&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;typeMappingRegistry&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;jaxbTypeMappingRegistry&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;xfire&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;xfire&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;webAnnotations&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;webAnnotations&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.web.servlet.handler.SimpleUrlHandlerMapping&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;urlMap&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;handlerMapping&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Add xfire-servlet.xml  into the Spring&#8217;s contextConfigLocation and XFireServlet in <strong>web.xml</strong> file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>contextConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    /WEB-INF/applicationContext.xml
    /WEB-INF/xfire-servlet.xml
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XFireServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XFire Servlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.xfire.spring.XFireSpringServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XFireServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/servlet/XFireServlet/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XFireServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/services/v1/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Let&#8217;s have a simply <strong>MinimizrFacade.java</strong> Java interface:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.minimizr.service</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.minimizr.service.domain.ExampleObject</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> MinimizrFacade <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">String</span> getString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">String</span> echoString<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> string<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ExampleObject echoObject<span style="color: #009900;">&#40;</span>ExampleObject exampleObject<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  List<span style="color: #339933;">&lt;</span>exampleObject<span style="color: #339933;">&gt;</span> loadExampleObjectList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And let&#8217;s have another <strong>MinimizrService.java</strong> Java interface for web services:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.minimizr.service</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebService</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.minimizr.service.domain.ExampleObject</span><span style="color: #339933;">;</span>
&nbsp;
@WebService
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> MinimizrService <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">String</span> getString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">String</span> echoString<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> string<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ExampleObject echoObject<span style="color: #009900;">&#40;</span>ExampleObject exampleObject<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  List<span style="color: #339933;">&lt;</span>exampleObject<span style="color: #339933;">&gt;</span> loadExampleObjectList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And for this example a <strong>ExampleObject.java</strong> Java object:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.minimizr.service</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleObject <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> age<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> getAge<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> age<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setAge<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> age<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">age</span> <span style="color: #339933;">=</span> age<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> name<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And finally a <strong>MinimizrImpl.java</strong> Java implementation for the interfaces:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.minimizr.domain.logic</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebService</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.minimizr.service.ExampleObject</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.minimizr.service.MinimizrService</span><span style="color: #339933;">;</span>
&nbsp;
@WebService<span style="color: #009900;">&#40;</span>serviceName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;MinimizrService&quot;</span>,
    endpointInterface <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;com.minimizr.service.MinimizrService&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MinimizrImpl <span style="color: #000000; font-weight: bold;">implements</span> MinimizrFacade, MinimizrService <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Example string&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> echoString<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> string<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> string<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> ExampleObject echoObject<span style="color: #009900;">&#40;</span>ExampleObject exampleObject<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> exampleObject<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> loadExampleObjectList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">/* Here you would get list of ExampleObjects for example from database
    and return it instead of null */</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>XFire does not support <a href="http://jira.codehaus.org/browse/XFIRE-425">RPC-encoding</a> but you can use <a href="http://docs.codehaus.org/display/XFIRE/PHP+Interoperation">XFire web services with PHP</a> with document/literal style of SOAP.</p>
<p>Here is a really simple example to use all the exposed java web services in this example with <a href="http://sourceforge.net/projects/nusoap/">NuSOAP</a> PHP SOAP library. There are <ins datetime="2006-12-02T13:42:02+00:00">no</ins> checks for errors in the code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;../lib/nusoap.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$soapClient</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> soapclient<span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&quot;http://www.minimizr.com/ws/services/v1/MinimizrService?wsdl&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wsdl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$proxyClass</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$soapClient</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProxy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// getString</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$proxyClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;b&gt;String:&lt;/b&gt; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;out&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;hr/&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// echoString</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$proxyClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">echoString</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;in0&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;ABC&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;b&gt;String:&lt;/b&gt; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;out&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;hr/&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// echoObject</span>
<span style="color: #000088;">$requestObject</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;John&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;age&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$proxyClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">echoObject</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;in0&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$requestObject</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$resultObject</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;out&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;b&gt;Object:&lt;/b&gt; name: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$resultObject</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;, age: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$resultObject</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;age&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;hr/&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// loadExampleObjectList</span>
<span style="color: #000088;">$exampleObjectList</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$proxyClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadExampleObjectList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$exampleObjectList</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;out&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ExampleObject&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;age&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>Authentication</h4>
<p><em>Added November 14, 2006</em>: Well, easiest and most straightforward way to secure web service is to use HTTP Authentication. It doesn&#8217;t need any additional code in the server side. While still looking for solution to use easily Acegi Security, I&#8217;ll add HTTP Authentication to this example. On the server side you&#8217;ll have to add security constraint into <strong>web.xml</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;security-constraint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;web-resource-collection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;web-resource-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Protected Minimizr Web Services<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/web-resource-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/services/v1/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/web-resource-collection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;auth-constraint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;role-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>minimizr.webservices.client<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/role-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/auth-constraint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/security-constraint<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;login-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;auth-method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>BASIC<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/auth-method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;realm-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Minimizr Realm<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/realm-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/login-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;security-role<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Required roles to use the Web Services<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;role-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>minimizr.webservices.client<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/role-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/security-role<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And couple more lines into the PHP file. Credentials must be added into the wsdl url and proxy class. Notice that it is quite necessary to use SSL connection (https) with basic authentication since username and password are in clear text. You can use useHTTPPersistentConnection method to use persistent connection, if possible:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;../lib/nusoap.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;basic&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$soapClient</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> soapclient<span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">&quot;https://<span style="color: #006699; font-weight: bold;">$username</span>:<span style="color: #006699; font-weight: bold;">$password</span>@www.minimizr.com/ws/services/v1/MinimizrService?wsdl&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">&quot;wsdl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$proxyClass</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$soapClient</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProxy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$proxyClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCredentials</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #339933;">,</span> <span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$proxyClass</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">useHTTPPersistentConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">...</span></pre></div></div>

<h4>Conclusion</h4>
<p>It is no brainer to expose Java POJOs as web services with Spring, XFire and JSR-181 annotations. And it is as easy use those web services with Java or PHP or other platforms. I guess integrating <a href="http://www.acegisecurity.org/">Acegi Security</a> with XFire web services needs a little bit more work. Any suggestions for the easiest way to implement it?</p>
<h4>Additional recourses</h4>
<ul>
<li><a href="http://www.logemann.org/blojsom/blog/default/2006/05/26/Webservices-with-Spring-XFire-and-jsr181.html">Webservices with Spring, XFire and jsr181</a></li>
<li><a href="http://www.memestorm.com/blog/basic-spring-web-services-with-xfire-and-jsr-181/">Basic Spring Web services with XFire and JSR 181</a></li>
<li><a href="http://wiki.firebright.com/bin/view/Main/SpringHibernateXFire"> Spring, Hibernate, and XFire</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://minimizr.com/blog/2006/11/minimal-web-services-with-xfire-spring-and-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minimal How to Use Google Maps API With PHP</title>
		<link>http://minimizr.com/blog/2006/10/minimal-how-to-use-google-maps-api-with-php/</link>
		<comments>http://minimizr.com/blog/2006/10/minimal-how-to-use-google-maps-api-with-php/#comments</comments>
		<pubDate>Sat, 21 Oct 2006 13:39:35 +0000</pubDate>
		<dc:creator>kristian</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.minimizr.com/blog/2006/10/minimal-how-to-use-google-maps-api-with-php/</guid>
		<description><![CDATA[The goal of this how to is to easily add multiple markes into the map on your own site using Google Maps API and PHP. Google Maps API key If you don&#8217;t already have, sign up for the Google Account. Sign up for the Google Maps API key. Read at least the higlights from the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.google.com/apis/maps/"><img id="image35" src="http://www.minimizr.com/wp-content/uploads/minimizr.com/2006/10/post-google-maps-php.gif" alt="Google Maps" style="float:right;margin-left:10px;"/></a><span class="summary"><strong>The goal of this how to is to easily add multiple markes into the map on your own site using Google Maps API and PHP.</strong></span></p>
<h4>Google Maps API key</h4>
<ol>
<li>If you don&#8217;t already have, sign up for the <a href="http://www.google.com/accounts/">Google Account</a>.</li>
<li>Sign up for the <a href="http://www.google.com/apis/maps/signup.html">Google Maps API key.</a> Read at least the higlights from the Google Maps API terms. Sign up for your site, forexample <em>http://www.mysite.com/</em></li>
</ol>
<p>After sign up you&#8217;ll get your key and an example html code. If you lost your key anytime, you can sign up again for the same site and use a new key. You can also sign up for multiple sites keys if needed. You&#8217;ll get different key for each site.</p>
<h4>JavaScript</h4>
<p>To add multiple markers on your map we&#8217;ll use some basic PHP code. Google&#8217;s example code is a good starting point for this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0</span>
<span style="color: #00bbdd;">  Strict//EN&quot;</span>
<span style="color: #00bbdd;">  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content-type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html;</span>
<span style="color: #009900;">    charset=utf-8&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Google Maps JavaScript API Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://maps.google.com/maps?</span>
<span style="color: #009900;">      file=api&amp;amp;v=2&amp;amp;key=ABCDEFGH...&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
    //<span style="color: #009900;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #009900;">    function load<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">      if <span style="color: #66cc66;">&#40;</span>GBrowserIsCompatible<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">        var map <span style="color: #66cc66;">=</span> new GMap2<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        document.getElementById<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;map&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        map.setCenter<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        new GLatLng<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">37.4419</span>, -<span style="color: #cc66cc;">122.1419</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">      <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">    <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">    <span style="color: #66cc66;">//</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;load()&quot;</span> <span style="color: #000066;">onunload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;GUnload()&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 500px; height: 300px&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>You have your API key on the html head and JavaScript to load on page load and div element to show the map. With map.setCenter(new GLatLng(37.4419, -122.1419), 13) you define the map&#8217;s center point and the zoom level. Here is an <a href="http://www.minimizr.com/example/2006/10/minimal-how-to-google-maps-api-with-php-1.php">example</a>.</p>
<p>To have some controls in the map, add this line into JavaScript load funtion:</p>
<pre>map.addControl(new GSmallMapControl());</pre>
<p>Add this JavaScript function to make markers:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> createMarker<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> text<span style="color: #339933;">,</span> title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> marker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GMarker<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span>title<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  GEvent.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    marker.<span style="color: #660066;">openInfoWindowHtml</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> marker<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Add marker with this code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> marker <span style="color: #339933;">=</span> createMarker<span style="color: #009900;">&#40;</span>
<span style="color: #003366; font-weight: bold;">new</span> GLatLng<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">37.4419</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">122.1419</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">'Marker text'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Example Title text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
map.<span style="color: #660066;">addOverlay</span><span style="color: #009900;">&#40;</span>marker<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note that you can add in the markers any html code like links and images for example. So, the code looks now like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0</span>
<span style="color: #00bbdd;">  Strict//EN&quot;</span>
<span style="color: #00bbdd;">  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content-type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html;</span>
<span style="color: #009900;">    charset=utf-8&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Google Maps JavaScript API Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://maps.google.com/maps?</span>
<span style="color: #009900;">      file=api&amp;amp;v=2&amp;amp;key=ABCDEFGH...&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
    //<span style="color: #009900;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #009900;">    function load<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">      if <span style="color: #66cc66;">&#40;</span>GBrowserIsCompatible<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">        var map <span style="color: #66cc66;">=</span> new GMap2<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        document.getElementById<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;map&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        map.addControl<span style="color: #66cc66;">&#40;</span>new GSmallMapControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        map.setCenter<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        new GLatLng<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">37.4419</span>, -<span style="color: #cc66cc;">122.1419</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        function createMarker<span style="color: #66cc66;">&#40;</span>point, <span style="color: #000066;">text</span>, <span style="color: #000066;">title</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">          var marker <span style="color: #66cc66;">=</span></span>
<span style="color: #009900;">          new GMarker<span style="color: #66cc66;">&#40;</span>point,<span style="color: #66cc66;">&#123;</span><span style="color: #000066;">title</span>:<span style="color: #000066;">title</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">          GEvent.addListener<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">          marker, <span style="color: #ff0000;">&quot;click&quot;</span>, function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">            marker.openInfoWindowHtml<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">text</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">          <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">          return marker;</span>
<span style="color: #009900;">        <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">        var marker <span style="color: #66cc66;">=</span> createMarker<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        new GLatLng<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">37.4419</span>, -<span style="color: #cc66cc;">122.1419</span><span style="color: #66cc66;">&#41;</span>,</span>
<span style="color: #009900;">        <span style="color: #ff0000;">'Marker text'</span>, <span style="color: #ff0000;">'Example Title text'</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        map.addOverlay<span style="color: #66cc66;">&#40;</span>marker<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">      <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">    <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">    <span style="color: #66cc66;">//</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;load()&quot;</span> <span style="color: #000066;">onunload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;GUnload()&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 500px; height: 300px&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Here is an <a href="http://www.minimizr.com/example/2006/10/minimal-how-to-google-maps-api-with-php-2.php">example</a>.</p>
<h4>PHP</h4>
<p>In order to add multiple markes, we&#8217;ll use some PHP to iterate over some marker points. Let&#8217;s use an array in this example, but you could get the marker points for example from database or xml file. Put the following lines around marker adding lines:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$points</span> <span style="color: #339933;">=</span> <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;37.4389, -122.1389&quot;</span><span style="color: #339933;">,</span>
<span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;37.4419, -122.1419&quot;</span><span style="color: #339933;">,</span>
<span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;37.4449, -122.1449&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$points</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$point</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
var marker = createMarker(
new GLatLng(<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$point</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>),
'Marker text <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>',
'Example Title text <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>');
map.addOverlay(marker);
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>And here is the final code:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0</span>
<span style="color: #00bbdd;">  Strict//EN&quot;</span>
<span style="color: #00bbdd;">  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content-type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html;</span>
<span style="color: #009900;">    charset=utf-8&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Google Maps JavaScript API Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://maps.google.com/maps?</span>
<span style="color: #009900;">      file=api&amp;amp;v=2&amp;amp;key=ABCDEFGH...&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
    //<span style="color: #009900;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #009900;">    function load<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">      if <span style="color: #66cc66;">&#40;</span>GBrowserIsCompatible<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">        var map <span style="color: #66cc66;">=</span> new GMap2<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        document.getElementById<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;map&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        map.addControl<span style="color: #66cc66;">&#40;</span>new GSmallMapControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        map.setCenter<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        new GLatLng<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">37.4419</span>, -<span style="color: #cc66cc;">122.1419</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">        function createMarker<span style="color: #66cc66;">&#40;</span>point, <span style="color: #000066;">text</span>, <span style="color: #000066;">title</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">          var marker <span style="color: #66cc66;">=</span></span>
<span style="color: #009900;">          new GMarker<span style="color: #66cc66;">&#40;</span>point,<span style="color: #66cc66;">&#123;</span><span style="color: #000066;">title</span>:<span style="color: #000066;">title</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">          GEvent.addListener<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">          marker, <span style="color: #ff0000;">&quot;click&quot;</span>, function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">            marker.openInfoWindowHtml<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">text</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">          <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #009900;">          return marker;</span>
<span style="color: #009900;">        <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">        &lt;?php</span>
<span style="color: #009900;">        $points <span style="color: #66cc66;">=</span> Array<span style="color: #66cc66;">&#40;</span></span>
<span style="color: #009900;">        <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">=</span>&gt;</span> &quot;37.4389, -122.1389&quot;,
        2 =&gt; &quot;37.4419, -122.1419&quot;,
        3 =&gt; &quot;37.4449, -122.1449&quot;);
        foreach ($points as $key =&gt; $point) {
        ?&gt;
        var marker = createMarker(
        new GLatLng(<span style="color: #009900;">&lt;?php echo $point ?&gt;</span>),
        'Marker text <span style="color: #009900;">&lt;?php echo $key ?&gt;</span>',
        'Example Title text <span style="color: #009900;">&lt;?php echo $key ?&gt;</span>');
        map.addOverlay(marker);
        <span style="color: #009900;">&lt;?php <span style="color: #66cc66;">&#125;</span> ?&gt;</span>
      }
    }
    //]]&gt;
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;load()&quot;</span> <span style="color: #000066;">onunload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;GUnload()&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 500px; height: 300px&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>And here is the final <a href="http://www.minimizr.com/example/2006/10/minimal-how-to-google-maps-api-with-php-3.php">example</a>.</p>
<p>If you have let&#8217;s say hundereds or thousands and more markers in your map, you might want to give a try to <a href="http://www.acme.com/javascript/#Clusterer">Clusterer</a>. It is an excellent and easy to use JavaScript library by Jef Poskanzer.</p>
<p>This how to showed only very basic usage of Google Maps API. To learn more Google Maps API has a good <a href="http://www.google.com/apis/maps/documentation/">documentation</a> and <a href="http://www.econym.demon.co.uk/">Mike</a> has many excellent <a href="http://www.econym.demon.co.uk/googlemaps/index.htm">examples</a> of the basics and more andvanced stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://minimizr.com/blog/2006/10/minimal-how-to-use-google-maps-api-with-php/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

