»
S
I
D
E
B
A
R
«
Sponsored Links
Vork, open-source PHP framework designed for rapid development of performance-oriented scalable applications
Feb 24th, 2010 by NewUser

Vork Enterprise PHP Framework

Vork is an open-source PHP framework designed for rapid development of performance-oriented scalable applications.

The mission of Vork is to provide an MVC architecture and full-featured toolkit in a gimmick-free no-frills approach without adding overhead, creating slow & unscalable abstraction layers or re-inventing native PHP functionality.

Rapid Application Development

  • Native PHP interface with intuitive naming convention, no need to learn new terminology or syntax
  • Hello World! in 5-minutes or less with LAMP/WAMP configuration
  • Developers that already know PHP can use Vork productively within minutes

Performance-Oriented, Scalable, Green and Economical

  • Green-IT: Vork applications serve more traffic with less servers!
  • Enterprise-grade Vork platform has no slow abstraction layers or re-invented PHP functionality
  • Out-of-the-box response time for a Hello World! including making a database connection is typically just 0.0065 seconds!
  • Built-in support for multiple master/slave database configurations with tools to enforce security and increase SQL-statement efficiency
  • Automatically loads code & objects that are needed for the instance and not a byte more!
  • Vork can be configured to operate without any disk-IO to further reduce load time

Standards-Compliant

  • XHTML 1.1
  • PHP 5.0 – 5.3+
  • E_ALL | E_STRICT
  • Section 508
  • W3C WAI
  • Full MVC stack including layouts and components
  • All tools produce valid XHTML 1.1 with semantically-correct markup
  • Accessibility is automated as much as possible to meet Section 508 and W3C WAI standards
  • Code is open-source, built for PHP 5 and fully documented using the phpDocumentor DocBlock standard
  • Universal database support without abstraction layers; ability to easily change database brands at any time
  • Object-oriented source code is E_ALL | E_STRICT and adheres to the Zend Framework Coding Standards
  • Concise URL format is ideal for search engine optimization (SEO) and is easy to communicate verbally
  • CakePHP and Zend Framework objects can be imported into Vork; Vork Helpers and components can be used within Zend Framework and CakePHP
  • CSS-reset with default styles to provide cross-browser display consistency verified in Firefox, Google Chrome, Safari (OS X, iPhone & Windows) and IE6, 7 & 8

Extensive Toolset

  • E-commerce tools to validate & charge credit cards, accept PayPal payments, get UPS shipping rates, track a package, generate QR codes & more!Vork can generate QR codes and 3D charts!
  • Simplified use of Google tools: Maps, Charts, Analytics, AdSense, Sitemap, Payments, Translate
  • Amazon Web Services connection interface with automated caching mechanism
  • One-line of code turns any controller or action into a full-featured Wiki including a Wiki search engine
  • Forms maintain state automatically + ample tools include a WYSIWYG textarea that produces valid XHTML 1.1 markup and works in every browser
  • Internationalization (i18n) – multilingual forms allow users to easily type characters in other alphabets by pressing the phonetically-equivalent English keys
  • Integration with all mainstream JavaScript frameworks: YUI, jQuery, Prototype, MooTools, script.aculo.us, Dojo, SWFObject, Ext Core, Chrome Frame
  • Universal log-in/log-out/forgot-password utility
  • Turn any page of your application into a URL shortening site
  • User input validity is verified both in JavaScript (for user-experience) and in PHP (for security) – form validation rules are only written once
  • Extensive HTML helper functions including generation of Twitter Tweet links, tag clouds and simplified embedding of Adobe Flash
  • Consistent interface to many 3rd-party tools including Meetup event management & sharing boxes like: // Bookmark and Share
  • Email tools including outgoing-mail templates that operate like MVC-elements & spam-proof email address display tools
  • AJAX tools including inline language translation and simplified data-loading
  • Completely automatic SSL-link management to simplify transitions between https:// and http:// pages
  • Image management tools to watermark an uploaded image + generate multiple images in different sizes (fullsize, thumbnail, etc.)
  • POST utility to simplify connecting to web services
  • Effortless media integration including Flickr feeds, YouTube videos and embedding an MP3 player
  • Default 404 “not found” page has a Google Search box pre-populated to search your site for content related to the missing page
  • RSS layout makes it easy for any PHP array to become an RSS 2.0 or Atom feed; RSS reader makes quick work of syndicating feeds
  • Debugging tools that output to your Firefox Firebug console

Requirements

  • PHP – any version between 5.0.2 and 5.3.x
  • A database is optional and any database or cloud-DB that is supported by PHP will work with Vork
  • Works on any web server (Apache, Microsoft IIS, etc.)
  • Works with any operating system (Linux, Windows, Mac OS X, FreeBSD, etc.)
  • Integrated caching through any package with a PHP interface (Memcached, etc.)
Get a URL’s Reddit Score Using PHP and JSON
Nov 11th, 2009 by wood
Reddit Guy

Since we can see Digg turning more into a funny-pic-and-vid site each day, I’ve turned my attention to Reddit. Reddit just seems more controlled and programmer-friendly. Since I have respect for Reddit I thought I’d put together a quick tutorial on how you can retrieve a URL’s Reddit score using PHP.

The PHP

<?php

	/* settings */
	$url = 'http://davidwalsh.name/9-signs-not-to-hire-that-web-guy';
	$reddit_url = 'http://www.reddit.com/api/info.{format}?url='.$url;
	$format = 'json'; //use XML if you'd like...JSON FTW!
	$score = $ups = $downs = 0; //initialize

	/* action */
	$content = get_url(str_replace('{format}',$format,$reddit_url)); //again, can be xml or json
	if($content) {
		if($format == 'json') {
			$json = json_decode($content,true);
			foreach($json['data']['children'] as $child) { // we want all children for this example
				$ups+= (int) $child['data']['ups'];
				$downs+= (int) $child['data']['downs'];
				//$score+= (int) $child['data']['score']; //if you just want to grab the score directly
			}
			$score = $ups - $downs;
		}
	}

	/* output */
	echo "Ups: $ups<br />"; //21
	echo "Downs: $downs<br />"; //8
	echo "Score:  $score<br />"; //13

	/* utility function:  go get it! */
	function get_url($url) {
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_URL,$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1);
		$content = curl_exec($ch);
		curl_close($ch);
		return $content;
	}

?>

Parsing the JSON is simple using json_encode with the value of true to make turn the JSON into an associate array. My example shows how you can grab the number of “ups” and “downs” — not just the score. As with every API/web service, I highly recommend caching the result of your request.

Don't forget to follow me on Twitter and be sure to visit Script & Style for the best Javascript and CSS articles around! Sponsor the David Walsh Blog and get your brand in front of several thousand users per day!

Get a URL’s Reddit Score Using PHP and JSON

Related posts:

  1. Create a Basic Web Service Using PHP, MySQL, XML, and JSON
  2. GoDaddy, cURL, HTTP, and 403 Errors
  3. Create Bit.ly Short URLs Using PHP
  4. Create a TinyURL with PHP
  5. Download a URL’s Content Using PHP cURL

Dynamically Create Charts Using jQuery Flot and Google Analytics
Oct 22nd, 2009 by wood

jQuery Flot

Earlier in the week I published a popular article titled Dynamically Create Charts Using MooTools MilkChart and Google Analytics. My post showed you how to use MooTools MilkChart and a splash of PHP to create beautiful charts of Google Analytics data. I was interested in seeing what jQuery had to offer in the charting department. jQuery Flot is what I found.

The PHP

/* defaults */
$month = date('n');
$year = date('Y');

/* submission? */
if($_GET['month'] || $_GET['year']):
	/* cleanse lookups */
	$month = (int) $_GET['month']; if(!$month) { $month = 1; }
	$year = (int) $_GET['year']; if(!$year) { $year = date('Y'); }
	/* retrieve information from google analytics */
	require 'ga/analytics.class.php';
	$analytics = new analytics('youraccount@gmail.com', 'password');
	$analytics->setProfileByName('yourdomain.com');
	$analytics->setMonth($month,$year);
	$visits = $analytics->getVisitors();
	$views = $analytics->getPageviews();
	/* build tables */
	if(count($visits)) {
		foreach($visits as $day=>$visit) { 
			$flot_datas_visits[] = '['.$day.','.$visit.']';
			$flot_datas_views[] = '['.$day.','.$views[$day].']';
		}
		$flot_data_visits = '['.implode(',',$flot_datas_visits).']';
		$flot_data_views = '['.implode(',',$flot_datas_views).']';
	}
endif;

The above code is the same as my MooTools post with the exception of the statistics output format. jQuery flot prefers arrays instead of a HTML table.

The jQuery Flot Javascript

$(document).ready(function() {
	var visits = <?php echo $flot_data_visits; ?>;
	var views = <?php echo $flot_data_views; ?>;
	$('#placeholder').css({
		height: '400px',
		width: '600px'
	});
	$.plot($('#placeholder'),[
			{ label: 'Visits', data: visits },
			{ label: 'Pageviews', data: views }
		],{
	        lines: { show: true },
	        points: { show: true },
	        grid: { backgroundColor: '#fffaff' }
	});
});

The above is a simple example of using jQuery Flot’s plot method. Simply provide the placeholder and statistical data from the PHP above.

Comparison

  • jQuery Flot provides IE support via ExCanvas, which is great.
  • MilkChart allows for pie charts while Flot doesn’t. I prefer pie charts to other chart types.
  • MilkChart allows for easy creation of charts from HTML tables (good for accessibility) while jQuery Flot requires an array syntax.

What do you think? Which method do you prefer?

Send article as PDF to: PDF Creator

Don't forget to follow me on Twitter and be sure to visit Script & Style for the best Javascript and CSS articles around! Sponsor the David Walsh Blog and get your brand in front of several thousand users per day!

Dynamically Create Charts Using jQuery Flot and Google Analytics

Related posts:

  1. Dynamically Create Charts Using MooTools MilkChart and Google Analytics
  2. Retrieve Google Analytics Visits and PageViews with PHP
  3. Secure (SSL) Google Analytics
  4. Track Ajax Link Clicks Using Google Analytics
  5. Track File Downloads in Google Analytics Using MooTools

Dynamically Create Charts Using MooTools MilkChart and Google Analytics
Oct 20th, 2009 by wood
MilkChart

The prospect of creating graphics charts with javascript is exciting. It’s also the perfect use of javascript — creating non-essential features with unobtrusive scripting. I’ve created a mix of PHP (the Analytics class), HTML, and MooTools javascript that will connect to Google Analytics, create an HTML table with the statistics for a given month, and use MooTools MilkChart to colorfully chart them out.

The PHP

/* defaults */
$month = date('n');
$year = date('Y');
$type = 'Column';

/* submission? */
if($_GET['month'] || $_GET['year']):
	/* cleanse lookups */
	$month = (int) $_GET['month']; if(!$month) { $month = 1; }
	$year = (int) $_GET['year']; if(!$year) { $year = date('Y'); }
	/* retrieve information from google analytics */
	require 'ga/analytics.class.php';
	$analytics = new analytics('youraccount@gmail.com', 'yourP@ss');
	$analytics->setProfileByName('yourdomain.com');
	$analytics->setMonth($month,$year);
	$visits = $analytics->getVisitors();
	$views = $analytics->getPageviews();
	/* build tables */
	if(count($visits)) {
		//visits - php
		$visits_table_data = '<table id="data-table-visits">';
		/* $visits_table_data.= '<thead><tr><th>Unique Visits</th><th>PageViews</th></tr></head><tbody>'; */
		$visits_table_data.= '<thead><tr><th>Unique Visits</th></tr></head><tbody>';
		foreach($visits as $day=>$visit) { 
			/*
			$visits_table_data.= '<tr><td>'.$visit.'</td><td>'.$views[$day].'</td></tr>'."\n"; 
			$visits_table_foot.= '<td>'.$day.'</td><td>'.$day.'</td>'."\n";
			*/
			$visits_table_data.= '<tr><td>'.$visit.'</td></tr>'."\n"; 
			$visits_table_foot.= '<td>'.$day.'</td>'."\n";
		}
		$visits_table_data.= '</tbody>';
		$visits_table_data.= '<tfoot><tr>'.$visits_table_foot.'</tr></tfoot>';
		$visits_table_data.= '</table>';
	}
endif;

It all kicks off with grabbing the information from Google Analytics. Simply provide the time frame you would like statistics for. I usually choose to retrieve statistics by the month.

The Generated HTML & MooTools Javascript

<h2>Select Your Month/Year</h2>
<form method="get">
	<select name="month" id="month">
		<option value="">-- Select Month --</option>
		<?php
			for($x = 1; $x <= 12; $x++):
				echo '<option value="',$x,'"',($month == $x ? ' selected="selected"' : ''),'>',date('F',mktime(0,0,0,$x,1,2009)),'</option>';
			endfor;
		?>
	</select>
	<select name="year" id="year">
		<option value="">-- Select Year --</option>
		<?php
			for($x = 2008; $x <= date('Y'); $x++):
				echo '<option value="',$x,'"',($year == $x ? ' selected="selected"' : ''),'>',$x,'</option>';
			endfor;
		?>
	</select>
	<select name="type" id="type">
		<option value="">-- Select Chart Type --</option>
		<?php
			$chart_types = array('Column','Bar','Line','Scatter','Pie');
			foreach($chart_types as $chart_type):
				echo '<option value="',$chart_type,'"',($type == $chart_type ? ' selected="selected"' : ''),'>',$chart_type,'</option>';
			endforeach;
		?>
	</select>
	<input type="submit" name="submit" id="submit" value="Get Statistics!" />
</form>

<?php 
	//php time - echo tables
	if($visits_table_data) { echo '<h3>Visits</h3>', $visits_table_data,'<br />'; } 
?>
<?php if(count($visits)): ?>
	<script type="text/javascript">
		var visits = new MilkChart.<?php echo $_GET['type']; ?>('data-table-visits',{
			width: 960,
			height: 550,
			font: 'tahoma',
			showValues: false,
			useFooter: true
		});
	</script>
<?php endif; ?>

Using the THEAD, TBODY, and TFOOT elements is extremely important in the ensuring the correct labels are placed within the generated chart. The data table itself is very simple. MilkChart will take the above table and create a CANVAS element which will contain the chart.

There are five different chart types you may choose from: Column, Bar, Pie, Line, Scatter. MilkChart takes full advantage of MooTools’ inheritance model as each type of chart’s class extends the base MilkChart class.

I love the way the MilkChart developer(s) utilized MooTools’ OOP/inheritance model to perfection. I also love that MilkChart requires the bare minimum of data for the HTML table. MilkChart isn’t without its flaws though. A few of the table types had a fit about including multiple dimensions (using both page views and visits within the same chart, for example) and value label placement has yet to be perfected.

Send article as PDF to: PDF

Don't forget to follow me on Twitter and be sure to visit Script & Style for the best Javascript and CSS articles around! Sponsor the David Walsh Blog and get your brand in front of several thousand users per day!

Dynamically Create Charts Using MooTools MilkChart and Google Analytics

Related posts:

  1. Dynamically Create Charts Using jQuery Flot and Google Analytics
  2. Add Controls to the PHP Calendar
  3. Retrieve Google Analytics Visits and PageViews with PHP
  4. Track Ajax Link Clicks Using Google Analytics
  5. Secure (SSL) Google Analytics

Retrieve, Cache, and Display Your FeedBurner Subscriber Count
Oct 9th, 2009 by wood

One way of significantly speeding up your website is by caching information you retrieve remotely from other websites or databases. Caching information is extremely simple and can save your users seconds of unnecessary waiting. Here’s how I cache my FeedBurner follower count on my site.

The PHP

/* settings */
$cache_path = '/cache/';
$rss_file_name = date('Y-m-d').'-rss.txt';

/* rss */
if(file_exists($cache_path.$rss_file_name)) {
	$rss_subcribers = file_get_contents($cache_path.$rss_file_name);
}
else {
	$rss_content = get_url('https://feedburner.google.com/api/awareness/1.0/GetFeedData?id=dfadajf324789fhSDFDf48');
	$subscribers = get_match('/circulation="(.*)"/isU',$rss_content);
	if($subscribers) {
		$subscribers = number_format($subscribers,0,'',',');
		file_put_contents($cache_path.$rss_file_name,$subscribers);
		$rss_subcribers = $subscribers;
	}
}

/* display */
echo 'My subscriber count is: ',$rss_subscribers;

/* connects to the URL, returns content */
function get_url($url) {
	$ch = curl_init();
	curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1);
	$content = curl_exec($ch);
	curl_close($ch);
	return $content;
}

/* helper: does the regex */
function get_match($regex,$content) {
	preg_match($regex,$content,$matches);
	return $matches[1];
}

The first thing we do is check to see if our cached file exists. If it does, we simply return its contents. If the cache file doesn’t exist, we connect to our private FeedBurner URL, parse the content, and save the feed to a file named after the current day. Note the way we can check if we had gotten the count for the current day is by naming the file in “year-month-day” format.

Send article as PDF to: PDF Creator

Don't forget to follow me on Twitter and be sure to visit Script & Style for the best Javascript and CSS articles around! Sponsor the David Walsh Blog and get your brand in front of several thousand users per day!

Retrieve, Cache, and Display Your FeedBurner Subscriber Count

Related posts:

  1. Get Your FeedBurner Reader Statistic Using PHP cURL and the FeedBurner API
  2. Technorati Grabber: Get Your Technorati Rank and Authority
  3. Test Twitter Friendships with PHP
  4. PHP IMDB Information Grabber
  5. MSN Live Search Result Grabber



»  Substance: PHP Frameworks   »  SiteMap