<?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>Revolves &#187; PHP</title>
	<atom:link href="http://www.revolves.net/category/programming/php-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.revolves.net</link>
	<description>Innovation</description>
	<lastBuildDate>Tue, 27 Dec 2011 15:25:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>PHP Projects That Hobbyists Can Make &#8211; WordPress Plugins</title>
		<link>http://www.revolves.net/php-projects-that-hobbyists-can-make-wordpress-plugins/</link>
		<comments>http://www.revolves.net/php-projects-that-hobbyists-can-make-wordpress-plugins/#comments</comments>
		<pubDate>Sat, 28 May 2011 04:02:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=469</guid>
		<description><![CDATA[This question practically comes up in every beginners forum. Once you&#8217;ve learned a language, what should you make with it? Well, in this post, I specifically address one of the &#8220;type&#8221; of things you can make with PHP. I&#8217;ll also explain why there are great possibilities here. First of all, you already have a system [...]]]></description>
			<content:encoded><![CDATA[<p>This question practically comes up in every beginners forum. Once you&#8217;ve learned a language, what should you make with it? Well, in this post, I specifically address one of the &#8220;type&#8221; of things you can make with PHP. I&#8217;ll also explain why there are great possibilities here.<span id="more-469"></span></p>
<h2>First of all, you already have a system</h2>
<p>WordPress, though traditionally a blogging platform, can be used as a full-blown CMS if you want. Apart from making online publishing easy, it also has access level controls built-in.</p>
<p>WordPress allows you to add functionality that it already does not have. And while you attempt to do that, your plugin has access to all the functions and capabilities of WordPress.</p>
<p>Now, let me explain how you can get great ideas for WordPress&#8230;</p>
<h2>It may be common in PHP, but not in WordPress</h2>
<p>Many WordPress users are not so technically savvy that they can play with PHP files and configure them. We hackers like to do it, but it&#8217;s too inconvenient for them. So, all of the WordPress&#8217; plugins have an options panel that helps in easy configuration.</p>
<p>Do you remember writing or even seeing PHP pages that expire after a certain date, or a certain number of hours from the starting date? Well, it&#8217;s easy to write that. Just get the current time and find out if the page is supposed to be &#8220;expired.&#8221;</p>
<p>A beginning PHP programmer can easily make such a script. But such simple scripts are also available for download just in-case you don&#8217;t know PHP. They also come with simple instructions on modifying the script to specify the &#8220;exact time&#8221; of the expiration.</p>
<p>Now, that&#8217;s a very simple concept. A beginner would not be so delighted after writing such a script.</p>
<p>However, what if you wanted to do the same in WordPress. Let&#8217;s say you could set certain posts/pages to expire magically after a certain period of time?</p>
<p>But WordPress is different. Your script has to work seamlessly with WordPress, making sure that you allow your users to use your script without fiddling with any PHP files. You also need a clean interface where user can easily set and remove expiration.</p>
<p>Now, this simple task has become quite challenging. The challenge comes due to your concentration on making the script (now a WordPress plugin) as seamless as possible to use.</p>
<p>What could you do? Maybe you could have an expiration setting shown on each post or page&#8217;s edit page. Or maybe have a separate options panel where users can select pages/posts that they want to have expired. There are numerous design decisions you can make. It all depends on you and your taste.</p>
<p>Suddenly, the simple task of creating a simple PHP script has turned into a complex task of making it accessable to a certain subset of users. It&#8217;s challenging, and might keep you busy for a while. Your programming experience will also increase in the process.</p>
<p>So, just browse all those script directories and choose the ones you&#8217;d like to adapt to WordPress. And there you have a virtually infinite set of ideas for WordPress plugins.</p>
<h2>Where do I begin?</h2>
<p>Now that you&#8217;re charged up, I should also point you to some resources that will teach you how to create WordPress plugins.</p>
<p>I&#8217;d recommend starting with <a href="http://codex.wordpress.org/Writing_a_Plugin" target="_blank">Writing a Plugin &#8211; WordPress Codex</a>. Once you read that, you&#8217;ll also find a couple of links at the bottom referring to various tutorials.</p>
<h2>Go ahead and make &#8216;em</h2>
<p>Instead of creating just &#8220;test scripts,&#8221; you&#8217;d be creating stuff that people would want to use. So, what are you waiting for?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/php-projects-that-hobbyists-can-make-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Zend Acl With CodeIgniter</title>
		<link>http://www.revolves.net/using-zend-acl-with-codeigniter/</link>
		<comments>http://www.revolves.net/using-zend-acl-with-codeigniter/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 13:27:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=24</guid>
		<description><![CDATA[You&#8217;ll need to scroll horizontally to see the source codes. Best is to copy them and paste in your text editor I was just taking a look at the CodeIgniter forum, and found that many people require some sort of an Acl component to make their lives easier. Of course, Zend framework has an excellent [...]]]></description>
			<content:encoded><![CDATA[<p><em>You&#8217;ll need to scroll horizontally to see the source codes. Best is to copy them and paste in your text editor</em><br />
I was just taking a look at the CodeIgniter forum, and found that many people require some sort of an Acl component to make their lives easier. Of course, Zend framework has an excellent tried and tested Acl component. Also, the framework&#8217;s loose coupoling allows to just use a small part of it.</p>
<p>Seeing this, I tried implementing Zend&#8217;s Acl component into a default CI installation. Now, this is a very dirty work, I&#8217;ve just thrown stuffs here and there. But you&#8217;ll at least get an idea on how to use it. The major code goes into a CI library, which initializes the Acl object, roles, resources and rules for them.<br />
<span id="more-24"></span><br />
Lets begin with the directory structure,</p>
<p>I created a new directory called <i>Custom</i> inside the <i>application</i> directory. And here&#8217;s how the folder structure looks inside of <i>Custom</i>,</p>
<p>Custom<br />
 -Zend<br />
  &#8212;Acl<br />
  &#8212;Acl.php<br />
  &#8212;Exception.php (You&#8217;ll need this file too)</p>
<p>If you download the Zend framework, those are the only files you&#8217;ll need. Remember, you&#8217;ll need to have a folder called <i>Zend</i>, since this is how Zend refers to them in all of its includes. I apppend the <i>Custom</i> directory into PHP&#8217;s include path, since putting the <i>Zend</i> directory directly into the include path throws errors. That&#8217;s the reason I have the <i>Custom</i> folder in the first place. You&#8217;ll see all the include path stuff ahead, so don&#8217;t start worrying about them now.</p>
<p>Lets go to the library part. Now, lemme tell you beforehand that I&#8217;ve made no effort to organize code. My objective was to make the Acl component work in a convenient way. So pardon the bad coding practice if any <img src='http://www.revolves.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>In the <i>libraries</i> folder within your <i>application</i> folder, created a new library file named Zacl.php (I know I&#8217;m not creative). This is it&#8217;s contents.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Zacl
{
    function __construct()
    {
        session_start();
        //Append Zend's folder in PHP's include path
        set_include_path(get_include_path() . PATH_SEPARATOR . BASEPATH . &quot;application/Custom&quot;);

        //Load the Acl class
        require_once 'Zend/Acl.php';
        require_once 'Zend/Acl/Role.php';
        require_once 'Zend/Acl/Resource.php';

        //Create a new Acl object
        $this-&gt;acl = new Zend_Acl();

        /**
         * Add roles and resources. Check Zend's documentation for excellent
         * information on all these.
         * http://framework.zend.com/manual/en/zend.acl.html
         */
        $this-&gt;acl-&gt;addRole(new Zend_Acl_Role('guest'));
        $this-&gt;acl-&gt;addRole(new Zend_Acl_Role('users'),array('guest'));

        /**
         * Add some resources
         */
        $this-&gt;acl-&gt;add(new Zend_Acl_Resource('users_login'));
        $this-&gt;acl-&gt;add(new Zend_Acl_Resource('users_profile'));

        /**
         * Set rules for Acl
         */
        $this-&gt;acl-&gt;deny(); //Deny everything, so as to follow a whitelist approach.
        $this-&gt;acl-&gt;allow('guest','users_login');
        $this-&gt;acl-&gt;allow('users','users_profile');
    }

    function check_acl($resource)
    {
        if (!$this-&gt;acl-&gt;has($resource))
        {
            return 1;
        }

        if (isset($_SESSION['user_id']))
        {
            $role = 'users';
        }
        else
        {
            $role = 'guest';
        }

        return $this-&gt;acl-&gt;isAllowed($role,$resource);
    }

}</pre>
<p>Now, I have a constructor, which sets up everything. First of all, don&#8217;t be scared by the <i>session_start()</i> stuff, I just included it for a simple login/logout mechanism you&#8217;ll see later, to check if everythings fine. Even though I&#8217;ve commented the source code, I&#8217;ll just give a gist of what I&#8217;m doing.</p>
<p>1. Loading all required classes for Zend Acl.<br />
2. Adding Roles.<br />
3. Adding Resources (I elaborate on this below)<br />
4. Set access rules</p>
<p>If you see, the &#8216;users&#8217; role is actually a child of &#8216;guest&#8217; role, thus inheriting properties from it. You&#8217;ll need to check Zend&#8217;s manual to know about the syntax and stuff, since its explained quite well.</p>
<p>Now, both role and resource names are arbitrary. You can set them as whatever you want. I&#8217;ve used a small convention for resource part. I&#8217;ve named resources as &#8220;controller_action&#8221;. This is because, I can easily get controller and action name from the URI, and can easily query Acl from any controller.</p>
<p>In the next part, I simply set the access rules (quite self explanatory). I have a function called check_acl(), which takes a parameter named $resource. This is passed by the controller to the function, using the convention I told you about above. Zend throws an exception if a given resource couldn&#8217;t be found. Thus, if a resource is not in the Acl, I return 1, saying that its allowed to be accessed.</p>
<p>If the user has a session variable user_id, it means he&#8217;s logged in, thus I set his role to &#8216;users&#8217;. Else, his role is &#8216;guest&#8217;.</p>
<p>Now, to the controller path. I created a controller called Users, having this,</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

class Users extends Controller
{
    function __construct()
    {
        parent::__construct();
        $this-&gt;load-&gt;library('zacl');

        $resource = $this-&gt;uri-&gt;segment(1) . '_' . $this-&gt;uri-&gt;segment(2);
        if (!$this-&gt;zacl-&gt;check_acl($resource))
        {
            $this-&gt;load-&gt;helper('url');
            redirect('/users/login');
        }
    }

    function login()
    {
        echo &quot;The login page&quot;;
    }

    function profile()
    {
        echo &quot;The restricted profile page&lt;br /&gt;&quot;;
        echo &quot;Your user id: &quot; . $_SESSION['user_id'];
    }

    function setsess()
    {
        $_SESSION['user_id'] = 1;
    }

    function remsess()
    {
        unset($_SESSION['user_id']);
    }
}</pre>
<p>In the constructor, I load the Acl library, and pass the controller_action to check_acl() function. If the output is 1, user is allowed, else he isn&#8217;t. If he isn&#8217;t, I redirect him to login page.</p>
<p>The login() and profile() functions are simply dummy functions, to check if Acl is working properly. If you look at the library, you&#8217;ll find that guest cannot access profile, while only a user can. The setsess() and remsess() functions are to set and remove user session to simulate logging in and logging out.</p>
<p>Well, I guess that&#8217;s it. I know I went a bit fast, but I really got tired typing this much. Anyways, if you have any sort of doubts, or if my code has some errors, please point out by commenting below! I&#8217;ve tested the above code in WAMP.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.revolves.net/playing-with-zend-framework-17/" rel="bookmark" title="December 3, 2008">Playing With Zend Framework 1.7</a></li>
<li><a href="http://www.revolves.net/an-update-on-my-zend-framework-17-experience/" rel="bookmark" title="December 7, 2008">An Update On My Zend Framework 1.7 Experience</a></li>
</ul>
<p><!-- Similar Posts took 4.213 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/using-zend-acl-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>An Update On My Zend Framework 1.7 Experience</title>
		<link>http://www.revolves.net/an-update-on-my-zend-framework-17-experience/</link>
		<comments>http://www.revolves.net/an-update-on-my-zend-framework-17-experience/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 16:22:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=20</guid>
		<description><![CDATA[I&#8217;ve fiddled with Zend Framework a bit, and even developed a simple MVC application structure, i.e. just the bare bones. Looking at my code, I though, initializing so many classes, is this Framework efficient? Efficiency is the concern of many programmers if their project is going to be hammered with high internet traffic. I noticed [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve fiddled with Zend Framework a bit, and even developed a simple MVC application structure, i.e. just the bare bones. Looking at my code, I though, initializing so many classes, is this Framework efficient?<br />
<span id="more-20"></span><br />
Efficiency is the concern of many programmers if their project is going to be hammered with high internet traffic. I noticed certain slowdowns in various requests, especially querying the ACL and Auth. But that was fine, since I didn&#8217;t do the necessary caching of configuration files.</p>
<p>But still, the amount of overhead was quite large if you&#8217;re planning on using a standard shared hosting. Luckily, Zend does provide a performance guide on the Zend Framework manual. If you follow it, you&#8217;ll surely be able to significantly improve the framework&#8217;s performance, but I still doubt if shared hosting would handle it with ease.</p>
<p>I&#8217;m currently developing a project with <a href="http://codeigniter.com/" rel="nofollow">CodeIgniter</a> 1.7.0 (the current version as of now), and it seems to be more than enough for what I need. With CI, the advantage is that you can start straight away, seeing the screencasts available on their websites. You&#8217;d understand most of the structural parts there itself, and a well written User Guide always to your rescue.</p>
<p>Its not that one framework is better than the other. Zend is definitely powerful, and I&#8217;m still learning new things about it everyday. I&#8217;m sure I&#8217;ll get an opportunity to use it in a real life project.</p>
<p>The choice of a framework should always be based on your convenience, your requirements, the overhead, and the platform selected for deployment. If I&#8217;m simply making a Contact Us form, I wont even be needing a framework (duh!).</p>
<p>I created a simple &#8220;test&#8221; application in CakePHP. Unfortunately, in my shared hosting, its caching didn&#8217;t work. The problem persisted even with default CakePHP setting (all directory structure etc.). The problem seems to be with the shared host, which I no longer use. I don&#8217;t really know what the problem was, but now everything&#8217;s fine with a good new host. CakePHP still is in RC3 as of now, and RC2 at the time of writing my &#8220;test&#8221; application.</p>
<p>Writing it took about a two to three days, because I was still learning CakePHP&#8217;s ORM and Naming Conventions, which I had to constantly refer to. It&#8217;ll become a habit soon, just need more experience. Because of the caching problem, I rewrote the entire application in a day (hey, it was really small) in pure PHP and Smarty especially for its built-in cache support and design/code separation.</p>
<p>It wasn&#8217;t that difficulty after all. But if I were to really develop the application, I&#8217;d have used a framework, for future scalability. For me, CI looks like a good choice for nice code organization, as well as basic Active Record and Validation support. Its quite feature rich, I must admit.</p>
<p>CakePHP is a real monster, but I&#8217;m still waiting it to come out of RC. As far as Zend is concerned, its quite great too, but I&#8217;ll need a resourceful server (not a weak shared hosting) for any serious decent traffic website.</p>
<p>Happy coding!<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.revolves.net/playing-with-zend-framework-17/" rel="bookmark" title="December 3, 2008">Playing With Zend Framework 1.7</a></li>
<li><a href="http://www.revolves.net/using-zend-acl-with-codeigniter/" rel="bookmark" title="December 18, 2008">Using Zend Acl With CodeIgniter</a></li>
</ul>
<p><!-- Similar Posts took 4.313 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/an-update-on-my-zend-framework-17-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing With Zend Framework 1.7</title>
		<link>http://www.revolves.net/playing-with-zend-framework-17/</link>
		<comments>http://www.revolves.net/playing-with-zend-framework-17/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 11:43:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.revolves.net/?p=17</guid>
		<description><![CDATA[I downloaded Zend Framework 1.7 a few days ago. So far, it looks like a great framework, backed by a good company. Previously, I learnt CakePHP 1.2 RC (I&#8217;m desparately waiting for 1.2 Final). CakePHP did have a good documentation, though lacking at some parts (especially the 1.2 version). But still, the usage for so [...]]]></description>
			<content:encoded><![CDATA[<p>I downloaded Zend Framework 1.7 a few days ago. So far, it looks like a great framework, backed by a good company.</p>
<p>Previously, I learnt CakePHP 1.2 RC (I&#8217;m desparately waiting for 1.2 Final). CakePHP did have a good documentation, though lacking at some parts (especially the 1.2 version). But still, the usage for so simple that you could, by yourself figure out many things. Code logically fitted into places.<span id="more-17"></span></p>
<p>Now, Zend Framework is a completely different monster. Instead of a large framework, its a collection of components, basically. You can use any component on its own, without using the entire library, as long as you also include dependencies. E.g., the Auth component would require Session component for storage, etc&#8230;</p>
<p>Zend Framework does have a good manual, covering practically all of its feature. You&#8217;d find some sort of code for all the components. But the problem is, in many cases, they are snippets. You may be able to use them if that&#8217;s the only component you&#8217;re ever going to use. But if you&#8217;re taking advantage of Zend Framework&#8217;s MVC structure, you might be clueless on where to put those codes, how to call them, when to call them etc.</p>
<p>If you&#8217;re just starting out with the Framework, I&#8217;d recommend going through the four screencasts. Then, watch the webinars on components of your interest, though they&#8217;re basically the same thing you&#8217;d see in the manual. But still, you can get some additional useful information in the webinars.</p>
<p>So far, I&#8217;ve been able to create the main index and bootstrap properly, along with understanding the significance of each statement I write. The AutoLoad feature of the framework is a real boon. You don&#8217;t need to scatter require or require_once statements all over your code. Zend Framework will load the class files automatically for you, if you follow the right convention (which you&#8217;ll learn in the manual and screencasts).</p>
<p>I even played with the Auth component, and it works like a charm. You can restrict access to certain controllers or even actions within controllers using Auth alone, but I&#8217;d always recommend using Acl for such things if you have more than 2 roles and need to restrict certain actions within controllers. It&#8217;ll save you a lot of typing in the end. A good tip to note here is that you can/should save the Acl roles/resources you&#8217;ve constructed in a cache (using Zend&#8217;s cache) or a file or in a database, so that you don&#8217;t need to have an overhead of constructing them everytime.</p>
<p>So far, I&#8217;ve been searching the internet for various tutorials on Zend tutorials. Many bloggers have posted tutorials on various sections of the framework, I&#8217;m assembling a list of tutorials I liked, and am soon going to post it here.</p>
<p>Well then, meet ya next time!<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.revolves.net/an-update-on-my-zend-framework-17-experience/" rel="bookmark" title="December 7, 2008">An Update On My Zend Framework 1.7 Experience</a></li>
<li><a href="http://www.revolves.net/using-zend-acl-with-codeigniter/" rel="bookmark" title="December 18, 2008">Using Zend Acl With CodeIgniter</a></li>
</ul>
<p><!-- Similar Posts took 4.153 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.revolves.net/playing-with-zend-framework-17/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Database Caching 21/47 queries in 0.028 seconds using disk: basic

Served from: www.revolves.net @ 2012-02-04 14:26:27 -->
