<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>success</status>
  <result>
    <project>
      <id>109918</id>
      <name>simpleurlmapper</name>
      <created_at>2008-12-27T15:25:19Z</created_at>
      <updated_at>2008-12-27T15:25:20Z</updated_at>
      <description>OverviewSimpleUrlMapper for PHP provide generic functionality for URL mapping and routing based on a simple implementation of URI Templates. SimpleUrlMapper allows you to define variables to be parsed out of URLs that match URI Templates with those variables, i.e. &quot;post_id&quot; and &quot;posts/{post_id}&quot; where &quot;post_id&quot; would potentially represent a blog post ID and &quot;posts/3&quot; would indicate a blog post ID of 3. 

UsageNote the callback functions specified for template and validations receive an associative array containing the value(s) of matched template variables from the URL. Assuming the URI template is: 

foos/{foo}/bars/{bar}/bazes/{baz} 
and for a matching URL: 

foos/1/bars/test/bazes/3 
the variable passed to the callback function would have the following values (shown using a PHP express that would generate the value): 

array('foo' =&gt; 1, 'bar' =&gt; 'test', 'baz' =&gt; 3); 
NOTES:URI Template should not include a leading slash. URI Template syntax based on URI Templates although it does not support full URI template syntax, it currently only supports named variables. ExampleThe following is taken from the test file packaged with the simpleurlmapper.php and was taken from working code for a WordPress image cropper plugin. 

	$path = (isset($_GET['path']) ? $_GET['path'] : 'images/123/crops/4/edit');

	require_once('simpleurlmapper.php');

	$url_mapper = new SimpleUrlMapper();
	$url_mapper-&gt;add_variable('image_id',
		array(
			'decription' =&gt; 'Positive integer matching a valid ID for an existing image in the media library.',
			'type' =&gt; 'integer',
			'validator' =&gt; 'validate_image_id',
		));
	$url_mapper-&gt;add_variable('crop_no',
		array(
			'decription' =&gt; 'Positive integer 1..{n} where {n} is the maximum number of predefined crop sizes required.',
			'type' =&gt; 'integer',
			'validator' =&gt; array(1,5),
		));
	$url_mapper-&gt;add_variable('post_id',
		array(
			'decription' =&gt; 'Positive integer matching a valid ID for an existing post.',
			'type' =&gt; 'integer',
			'validator' =&gt; 'validate_post_id',
		));
	$url_mapper-&gt;add_template('edit',
		array(
			'template' =&gt; 'images/{image_id}/crops/{crop_no}/edit',
			'action' =&gt; 'do_edit_crop',
		));
	$url_mapper-&gt;add_template('review',
		array(
			'template' =&gt; 'images/{image_id}/crops/review',
			'action' =&gt; 'do_review_crops',
		));
	$url_mapper-&gt;add_template('crop',
		array(
			'template' =&gt; 'images/{image_id}/crops/{crop_no}',
			'action' =&gt; 'do_crop',
		));
	$url_mapper-&gt;add_template('associate',
		array(
			'template' =&gt; 'images/{image_id}/posts/{post_id}',
			'action' =&gt; 'do_set_post_association',
		));
	$url_mapper-&gt;execute($path);

function do_edit_crop($data) {
	extract($data);
	print &quot;Do Edit Crop #$crop_no for Image ID $image_id\r\n
&quot;;
	return;
}
/*
	do_review_crops($data)
*/
function do_review_crops($data) {
	extract($data);
	print 'Do Review Crops';
	return;
}
/*
	do_crop($data)
*/
function do_crop($data) {
	extract($data);
	print 'Do Crop';
	return;
}
/*
	do_set_post_association($data)
*/
function do_set_post_association($data) {
	extract($data);
	print 'Do Set Association';
	return;
}

/*
	validate_image_id()
*/
function validate_image_id($value,$data) {
	print &quot;Validate Image ID $value\r\n
&quot;;
	return true;
}
/*
	validate_post_id()
*/
function validate_post_id($value,$data) {
	print &quot;Validate Post ID $value\r\n
&quot;;
	return true;
}HistoryI developed SimpleUrlMapper because I needed to create a set of RESTful services for use inside another framework, in this case WordPress. I build an image cropping plugin for WordPress and that plugin uses SimpleUrlMapper.  

I decided to release it as open-source in case others could benefit from it and in hopes I might find others willing to help me improve it.  

Future?I may or may not continue to improve SimpleUrlMapper, it all depends on where my project work takes me. I'm currently an independent consultant so if you would like to use it but need it modified to support your own specific use-cases such as improving performance when a large number of templates are used or to improve URI template support to cover more use-cases, contact me and we can discuss.</description>
      <homepage_url>http://code.google.com/p/simpleurlmapper</homepage_url>
      <download_url></download_url>
      <url_name>simpleurlmapper</url_name>
      <user_count>0</user_count>
      <average_rating></average_rating>
      <rating_count>0</rating_count>
      <analysis_id></analysis_id>
      <licenses>
        <license>
          <name>bsd</name>
          <nice_name>BSD Copyright</nice_name>
        </license>
      </licenses>
    </project>
  </result>
</response>
