<?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>Robert Basic &#187; php</title>
	<atom:link href="http://robertbasic.com/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://robertbasic.com/blog</link>
	<description>the magic of coding...</description>
	<lastBuildDate>Mon, 30 Jan 2012 13:15:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a chat bot with PHP and Dbus</title>
		<link>http://robertbasic.com/blog/creating-a-chat-bot-with-php-and-dbus/</link>
		<comments>http://robertbasic.com/blog/creating-a-chat-bot-with-php-and-dbus/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 19:22:52 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[dbus]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pidgin]]></category>
		<category><![CDATA[signals]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=1482</guid>
		<description><![CDATA[Now that we know how to use DBus to communicate with Pidgin from PHP and how to listen to DBus signals, it&#8217;s time to put it all together by creating a simple chat bot! Nothing fancy, just a simple script that runs somewhere on some server and, by using a Pidgin account, can respond to [...]]]></description>
			<content:encoded><![CDATA[<p>Now that we know how to <a href="http://robertbasic.com/blog/communicating-with-pidgin-from-php-via-d-bus/">use DBus to communicate with Pidgin from PHP</a> and how to <a href="http://robertbasic.com/blog/listening-to-dbus-signals-with-php/">listen to DBus signals</a>, it&#8217;s time to put it all together by creating a simple chat bot! Nothing fancy, just a simple script that runs somewhere on some server and, by using a Pidgin account, can respond to some basic queries we send it.</p>
<h3>What did we get?</h3>
<p>As we want our script to receive messages from an other account, first we need to listen to the <code>ReceivedImMsg</code> event on the <code>im.pidgin.purple.PurpleInterface</code> interface. The data we get with that event is the ID of receiver&#8217;s account, the sender of the message, the actual message and the conversation&#8217;s ID (and some flags which we&#8217;re not interested in):</p>
<pre name="code" class="php">
$interface = "im.pidgin.purple.PurpleInterface";
$method = "ReceivedImMsg";
if ($signal-&gt;matches($interface, $method)) {
    $data = $signal-&gt;getData()->getData();
    $receiver = $data[0];
    $sender = $data[1];
    $message = $data[2];
    $conversation = $data[3];
}
</pre>
<p>Of course, this is only for this one event, for data associated with other events see <a href="http://developer.pidgin.im/doxygen/dev/html/pages.html">Pidgin&#8217;s manual</a>.</p>
<h3>Who&#8217;s there?</h3>
<p>The event we are listening for will fire for any and all accounts, no matter who is the sender or the receiver of the message. We need to make sure that the receiving and the sending accounts are the correct ones, that the receiver is connected and that the receiver and the sender are contacts, &#8220;buddies&#8221;:</p>
<pre name="code" class="php">
if ($receiver == 2034 &#038;&#038; $proxy-&gt;PurpleAccountIsConnected($receiver)
    &#038;&#038; $proxy-&gt;PurpleFindBuddy($receiver, $sender) == 3681) {
</pre>
<p>The numbers 2034 and 3681 are the account IDs for my accounts I used in this example; you&#8217;ll need to figure out yours. </p>
<h3>Sending a response</h3>
<p>Now that we know who&#8217;s talking to whom, we can act upon the received message, do something with it, create a response message and send it back! The data we got with the event, has the ID of the conversation between the two accounts. We create a new instant message for that conversation and send it on it&#8217;s merry way with our clever response message:</p>
<pre name="code" class="php">
$im = $proxy-&gt;PurpleConvIm($conversation);
$proxy-&gt;PurpleConvImSend($im, $responseMessage);
</pre>
<p>As for what action the script can take upon a new message, is really up to the developer: it can do simple stuff like sending back the current uptime of the server or the current IP, running other tools like <a href="https://github.com/enygma/usher">usher</a> and sending that result back, or whatever is necessary.</p>
<h3>Daemonizing</h3>
<p>As this little bot is supposed to run on some server, the easiest way to run it as a &#8220;daemon&#8221; is to put the script in a background job via <a href="http://en.wikipedia.org/wiki/Nohup">nohup</a>:</p>
<pre name="code" class="php">
$ nohup php chat.php &#038;
</pre>
<p>If needed, <a href="http://kevin.vanzonneveld.net/techblog/article/create_daemons_in_php/">creating daemons in PHP</a> can be done too.</p>
<p>And that&#8217;s about all what&#8217;s needed to create a chat bot. See a complete example <a href="https://github.com/robertbasic/blog-examples/blob/master/dbus/chat.php">here on Github</a>.</p>
<p>As for, is PHP the right tool for creating this kind of thing, I don&#8217;t know, maybe, maybe not. What I do know, is that I had fun writing all this and I learned a lot along the way :)</p>
<p>Happy hackin&#8217;!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/creating-a-chat-bot-with-php-and-dbus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listening to Dbus signals with PHP</title>
		<link>http://robertbasic.com/blog/listening-to-dbus-signals-with-php/</link>
		<comments>http://robertbasic.com/blog/listening-to-dbus-signals-with-php/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 13:50:17 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[dbus]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[listen]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pidgin]]></category>
		<category><![CDATA[signals]]></category>
		<category><![CDATA[xmpp]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=1442</guid>
		<description><![CDATA[In my previous post I described (tried, at least) how to communicate with Pidgin from PHP, by using the Dbus PHP extension. The good part is that not can we only call different methods against Pidgin&#8217;s libpurple API, we can also listen to different signals on different events, that are sent via Dbus. Some of [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post I described (tried, at least) <a href="http://robertbasic.com/blog/communicating-with-pidgin-from-php-via-d-bus/">how to communicate with Pidgin from PHP</a>, by using the Dbus PHP extension.</p>
<p>The good part is that not can we only call different methods against Pidgin&#8217;s libpurple API, we can also listen to different signals on different events, that are sent via Dbus. Some of the events that are signalled are when a chat message is recieved, a friend comes online, a file is sent, or any other from a list of some 110 different events.</p>
<p>The PHP Dbus extension allows us to watch for one exact signal on an interface, or for all signals on an interface. Of course, we can add watches on multiple interfaces at once.</p>
<h3>Watching for signals</h3>
<p>Once we know the interface and/or the specific signal we&#8217;re interested in, we can add a watch on it. This is done by calling the <code>addWatch</code> method on the Dbus object, were the first parameter is the interface, and the second, <strong>optional</strong> parameter is the exact signal we want to listen to.</p>
<pre name="code" class="php">
&lt;?php

$dbus = new Dbus(Dbus::BUS_SESSION);

// watching for a specific signal
$dbus-&gt;addWatch("im.pidgin.purple.PurpleInterface", "ReceivedImMsg");
// or watching on an entire interface
// $dbus-&gt;addWatch("im.pidgin.purple.PurpleInterface");
// also can listen to different interfaces at the same time
$dbus-&gt;addWatch("org.freedesktop.Hal.Device");
</pre>
<p>Next, we need a way to actually get these signals when the events occur. For this we are using the <code>waitLoop</code> method of the Dbus class. That method accepts a number as a parameter, which is the number of miliseconds it should wait between requests. If an event happened on the interface we&#8217;re watching, it will return the signal, which is a <code>DbusSignal</code>; otherwise we&#8217;ll get a null:</p>
<pre name="code" class="php">

do {
    $signal = $dbus-&gt;waitLoop(1000);

    if ($signal instanceof DbusSignal) {
        // even if we watch only for one signal on one interface
        // we still can get rubbish, so making sure this is what we need
        if($signal-&gt;matches("im.pidgin.purple.PurpleInterface","ReceivedImMsg")){
            // data is in this weird DbusSet object thingy
            $data = $signal-&gt;getData()-&gt;getData();
            echo "Got stuff!\n";
        }
    }
} while (true);
</pre>
<p>Once we got the signal, to make sure that the signal is really the one we&#8217;re interested in, we call the <code>matches</code> method on it. The first parameter is the interface and the second is the signal.</p>
<p>Each event has (can have? not sure yet) additional data associated with it. To get to it, for some odd reason, we need to call <code>getData()->getData()</code> on the signal; note that this is in case of listening on libpurple&#8217;s interfaces, not sure about others. Experiment. Also, what kind of data is returned, again, depends on the interface and/or the event &#8211; some return arrays, some strings.</p>
<p>Have a look at the <a href="https://github.com/robertbasic/blog-examples/tree/master/dbus">Github repo</a> for some more examples (the dbus-signals* files).</p>
<p>In the third, and probably last post in this dbus mini-series, I&#8217;ll try to build a bot with which I can communicate and issue out commands to.</p>
<p>Happy hackin&#8217;!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/listening-to-dbus-signals-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Communicating with Pidgin from PHP via D-Bus</title>
		<link>http://robertbasic.com/blog/communicating-with-pidgin-from-php-via-d-bus/</link>
		<comments>http://robertbasic.com/blog/communicating-with-pidgin-from-php-via-d-bus/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 21:10:43 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[dbus]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pidgin]]></category>
		<category><![CDATA[xmpp]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=1354</guid>
		<description><![CDATA[Earlier this week I got an idea of trying to communicate with Pidgin, a chat client, via the terminal. Sounded like a fun thing to hack on, plus, could be made useful (in my head, at least), for things like logging from a web application directly to IM, or, heck, even creating something like Github&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this week I got an idea of trying to communicate with <a href="http://pidgin.im/">Pidgin</a>, a chat client, via the terminal. Sounded like a fun thing to hack on, plus, could be made useful (in my head, at least), for things like logging from a web application directly to IM, or, heck, even creating something like <a href="https://github.com/github/hubot">Github&#8217;s Hubot</a>, commanding a server or an application just via chat. Surely I wasn&#8217;t the first one to come up with this idea and after a bit of a googling found out that Pidgin&#8217;s libpurple has a nice API for that, <a href="http://developer.pidgin.im/wiki/DbusHowto">exposed via D-Bus</a>.</p>
<p>I first planned to write some scripts for this in Python or C, but when I finally sat down over the weekend to hack on this, realized there is a <a href="http://pecl.php.net/package/DBus">PHP D-Bus extension</a>, thanks to <a href="http://derickrethans.nl/">Derick Rethans</a>! As I rarely have the opportunity/need to play with more &#8220;obscure&#8221; PHP extensions, decided to give this one a spin&#8230; (Note: apart from that D-Bus is used for processes communicating with each other, I have zero knowledge about it, so I might be wrong with some things down below.)</p>
<h3>Installing D-Bus for PHP</h3>
<p>As the extension requires the <code>dbus-devel</code> package, first make sure it is installed:</p>
<pre name="code" class="bash">
$ yum install dbus-devel
</pre>
<p>The installation of the extension itself is pretty easy:</p>
<pre name="code" class="bash">
$ pecl install dbus-beta
</pre>
<p>Add the <code>extension=dbus.so</code> line to your php.ini, restart Apache if needed and have a look at the <code>phpinfo();</code>, there should be an entry for D-Bus listed.</p>
<p>Note that there is no documentation for this extension at the moment, but, luckily, the sources include an <a href="http://svn.php.net/viewvc/pecl/dbus/trunk/examples/">examples directory</a> full of goodies! After fiddling around with those for an hour or so, got the basics of the extension figured out.</p>
<p>One thing I haven&#8217;t figured out completely, is how to run scripts which use the Dbus extension via the browser, as in those cases the scripts are dying with a terrible X11 error message. So, run Dbus scripts from the console and all should be fine. </p>
<h3>The a-ha! moment</h3>
<p>What I learned by looking at the examples, is that the Dbus class is used for creating a proxy, which can be used to call methods on the service/application we&#8217;re interested in. But, what methods are available, what arguments do those methods accept (if any), and what will they return as a result?</p>
<p>This can easily be found out by <strong>introspection</strong>. Create a proxy to an object which implements the <code>Introspectable</code> interface and call the <code>Introspect</code> method on that proxy:</p>
<pre name="code" class="php">
&lt;?php

$dbus = new Dbus;

$proxy = $dbus-&gt;createProxy("im.pidgin.purple.PurpleService",
                            "/im/pidgin/purple/PurpleObject",
                            "org.freedesktop.DBus.Introspectable");

$data = $proxy-&gt;Introspect();

file_put_contents('introspect.xml', $data);
</pre>
<p>As the result of the introspection is returned in an XML and can be quite big, putting it in a file for easier viewing.</p>
<p>By looking at the XML file, it&#8217;s pretty easy to figure out what&#8217;s going on; method names, method arguments, their names and types, and the returned result:</p>
<pre name="code" class="php">
<method name="PurpleAccountGetUsername">
  <arg name="account" type="i" direction="in"></arg>
  <arg name="RESULT" type="s" direction="out"></arg>
</method>
</pre>
<p>With all this information at our disposal, it&#8217;s easy to write a script which does something useful, like, listing all the connected accounts and the protocols they are using:</p>
<pre name="code" class="php">
&lt;?php

$dbus = new Dbus;

$proxy = $dbus-&gt;createProxy("im.pidgin.purple.PurpleService",
                            "/im/pidgin/purple/PurpleObject",
                            "im.pidgin.purple.PurpleInterface");

$accounts = $proxy-&gt;PurpleAccountsGetAllActive();

foreach ($accounts-&gt;getData() as $account) {
    if ($proxy-&gt;PurpleAccountIsConnected($account)) {
        $username = $proxy-&gt;PurpleAccountGetUsername($account);
        $protocolId = $proxy-&gt;PurpleAccountGetProtocolId($account);
        $protocolName = $proxy-&gt;PurpleAccountGetProtocolName($account);
        echo $username . " is connected on the " . $protocolName
                       . " (" . $protocolId . ") protocol.\n";
    }
}
</pre>
<p>A sample output would be something like: &#8220;robertbasic@irc.freenode.net is connected on the IRC (prpl-irc) protocol.&#8221;</p>
<h3>Next steps</h3>
<p>Of course, this is far from a chat bot which can execute commands on a remote server, but at least we have some foundation to build on. In the coming days I&#8217;ll try to figure out how to create a loop which can be used to listen to different purple events &#8211; when a contact comes online, a chat is sent, or received, etc.</p>
<p>Also, it is quite fun trying to figure out a PHP extension just by looking at examples and the C source itself. One can learn a lot this way.</p>
<p>Happy hackin&#8217;!</p>
<p>P.S.: Code samples are up on <a href="https://github.com/robertbasic/blog-examples/tree/master/dbus">Github</a>!</p>
<p>Update 2011-12-26: the 2nd post, <a href="http://robertbasic.com/blog/listening-to-dbus-signals-with-php/">listening to dbus signals with php</a>, is published!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/communicating-with-pidgin-from-php-via-d-bus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oktober(blog)fest!</title>
		<link>http://robertbasic.com/blog/oktoberblogfest/</link>
		<comments>http://robertbasic.com/blog/oktoberblogfest/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 15:00:14 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Blablabla]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[oktoberblogfest]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=1246</guid>
		<description><![CDATA[Just as we had a blog movement back in March, thanks to Stuart Herbert we now have a new one for October &#8211; Oktober(blog)fest! :) The rules are easy: Write a post called Oktober(blog)Fest. List some of the reasons you like blogs. Pledge to blog more the rest of the month. Share your thoughts on [...]]]></description>
			<content:encoded><![CDATA[<p>Just as we had a blog movement <a href="http://robertbasic.com/blog/ideas-of-march/">back in March</a>, thanks to <a href="https://twitter.com/#!/stuherbert">Stuart Herbert</a> we now have a new one for October &#8211; <a href="http://blog.stuartherbert.com/php/2011/10/03/we-need-an-oktoberblogfest/">Oktober(blog)fest</a>! :)</p>
<p>The rules are easy:</p>
<ul>
<li>Write a post called Oktober(blog)Fest.</li>
<li>    List some of the reasons you like blogs.</li>
<li>    Pledge to blog more the rest of the month.</li>
<li>    Share your thoughts on Twitter with the <a href="https://twitter.com/#!/search/oktoberblogfest">#oktoberblogfest</a> hashtag.</li>
<li>    If we all blog a little more than we normally would this month, maybe we can be reminded of all of the reasons blogs are great.</li>
</ul>
<p>Well, here I am, pledging that I&#8217;ll be blogging a bit more in the coming days/weeks/months. I really do like blogging, don&#8217;t know why am I so lazy about it.</p>
<p>Don&#8217;t expect anything revolutionary from me tho, heh. An update or two from this weeks <a href="http://robertbasic.com/blog/speaking-at-webkonf-2011/">Webkonf</a> and maybe some news from the Zend Framework 2 world :)</p>
<p>Happy hackin&#8217;!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/oktoberblogfest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Book review &#8211; Guide to Web Scraping with PHP</title>
		<link>http://robertbasic.com/blog/book-review-guide-to-web-scraping-with-php/</link>
		<comments>http://robertbasic.com/blog/book-review-guide-to-web-scraping-with-php/#comments</comments>
		<pubDate>Wed, 25 May 2011 19:38:12 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[about]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[web scraping]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=1135</guid>
		<description><![CDATA[It took me a while to grab myself a copy of Matthew Turland&#8217;s &#8220;Guide to Web Scraping with PHP&#8220;, but a few weeks ago a copy finally arrived and I had the pleasure of reading it. I planned to buy it right as the print copy was announced, but then realised that php&#124;arch accepts only [...]]]></description>
			<content:encoded><![CDATA[<p>It took me a while to grab myself a copy of <a href="http://matthewturland.com/">Matthew Turland&#8217;s</a> &#8220;<a href="http://www.phparch.com/books/phparchitects-guide-to-web-scraping-with-php/">Guide to Web Scraping with PHP</a>&#8220;, but a few weeks ago a copy finally arrived and I had the pleasure of reading it. I planned to buy it right as the print copy was announced, but then realised that php|arch accepts only PayPal as the payment method, which doesn&#8217;t work from Serbia, so I had to postpone the shopping for some better times. Fast forward 5-6 months and I found a copy on the Book Depository, which has no shipping costs! Yey!</p>
<div class="wp-caption alignright" style="width: 154px"><a href="http://www.phparch.com/books/phparchitects-guide-to-web-scraping-with-php/"><img alt="Guide to Web Scraping with PHP" src="https://lh4.googleusercontent.com/--XtaGSrskrw/Td1ZMgcsQBI/AAAAAAAAAm0/TMotn_Se-JY/s144/scrapebook.jpg" title="Guide to Web Scraping with PHP" width="144" height="108" /></a><p class="wp-caption-text">Guide to Web Scraping with PHP</p></div>
<p>My overall impression of the book is that it was worth the time and I&#8217;m really glad that I bought it. Matthew did a great job explaining all the tools we have at our disposal for writing web scrapers and how to use them. The chapter on HTTP at the beginning and a chapter with some tips and tricks at the end of the book, fit in great with the rest of the chapters, which are full of code examples. For the first reading, I&#8217;d recommend reading the book cover to cover, to get an overall view of all the tools presented, but later the chapters can be read independently.</p>
<p>As I said, the first chapter (actually, the second one, the first one is the introductory chapter :p), deals with the HTTP, especially with the parts of it which are needed for understanding, using and creating web scrapers.</p>
<p>The book then continues on different client libraries we can use to send HTTP requests and receive responses. Libraries like cURL or Zend_Http_Client are explained, but it is also explained how one can create his own using streams (the author does note that you&#8217;d be better of with an existing one!). For each of the tools it is described, how to handle things like authentication, redirects and timeouts, amongst others&#8230;</p>
<p>The second part of the book deals with preparing the documents for, and with the actual parsing of the data from these documents. Again, different tools are presented and explained, which one to use when and why. If none of the parsing tools can help, a most essential overview of the PCRE extension is given, too.</p>
<p>The book is finished with a nice &#8220;Tips and Tricks&#8221; chapter, which discusses real-time vs batch job scrapers, how to work with forms, the importance of unit testing&#8230; IMHO, without this last chapter, the book would not be finished.</p>
<p>I&#8217;m thinking hard right now, what bad things could I say about this book, but I can&#8217;t think of any. It is a guide, clear and straight-to-the-point, explaining what tools are there, which one to use and how for writing scrapers and that&#8217;s exactly what I wanted to know.</p>
<p>Yep, I&#8217;d recommend this book to anyone interested in web scraping with PHP :)</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/book-review-guide-to-web-scraping-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ideas of March</title>
		<link>http://robertbasic.com/blog/ideas-of-march/</link>
		<comments>http://robertbasic.com/blog/ideas-of-march/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 18:20:23 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Blablabla]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[ideas of march]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=1012</guid>
		<description><![CDATA[Apparently there&#8217;s this new movement in the PHP community, &#8220;Ideas of March&#8221;, where we all pledge that we will blog more about PHP and web dev and the community in general. So here I am, doing the same :) This will be a real test for me because for the 2 and a half years [...]]]></description>
			<content:encoded><![CDATA[<p>Apparently there&#8217;s this new movement in the PHP community, <a href="http://www.phpdeveloper.org/news/16047">&#8220;Ideas of March&#8221;</a>, where we all pledge that we will blog more about PHP and web dev and the community in general. So here I am, doing the same :)</p>
<p>This will be a real test for me because for the 2 and a half years of this blog I&#8217;ve published merely 60 posts. Why? Mostly because I was (am?) scared to just write more about things I&#8217;m interested in. But, as I really do like blogging and letting my thoughts out I&#8217;ll just have to do my best to write more :) and yes, it&#8217;ll still mostly be PHP related with some linux or javascript stuff here and there :)</p>
<p>To see who pledged to blog more in March, check out <a href="http://www.phpdeveloper.org/news/16047">the list on PHPDeveloper</a> or follow the movement <a href="http://search.twitter.com/search?q=%23ideasofmarch">on Twitter #ideasofmarch</a>.</p>
<p>Happy bloggin&#8217;!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/ideas-of-march/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A real gem &#8211; PHP_CompatInfo</title>
		<link>http://robertbasic.com/blog/a-real-gem-php_compatinfo/</link>
		<comments>http://robertbasic.com/blog/a-real-gem-php_compatinfo/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 20:25:06 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=986</guid>
		<description><![CDATA[Last night I was pondering how nice would it be to have a tool of some sort, that would simply spit out what version of PHP does my app require. Something like: here are my .php files, what PHP version and/or extensions do I need for it? First I thought about jumping right in and [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I was pondering how nice would it be to have a tool of some sort, that would simply spit out what version of PHP does my app require. Something like: here are my .php files, what PHP version and/or extensions do I need for it? First I thought about jumping right in and writing it myself, but hey, this kind of a tool sounds way to useful not to be written already! After a bit of a googling there it was: <a href="http://pear.php.net/package/PHP_CompatInfo">PHP_CompatInfo</a>. A nice PEAR package that can tell me everything I want about my code and even a bit more.</p>
<p>It tells what&#8217;s the minimum overall PHP version needed, all the PHP extensions used and the PHP versions and extensions file by file.</p>
<p>Installing PHP_CompatInfo is easy: <code>pear install php_compatinfo</code> and that&#8217;s about it. Using it isn&#8217;t much harder:</p>
<pre class="php" name="code">
&lt;?php

require_once 'PHP/CompatInfo.php';

$source = '/home/robert/www/Zend/';

$driverType = 'xml';
$driverOptions = array();

$info = new PHP_CompatInfo($driverType, $driverOptions);
$info-&gt;parseDir($source);
</pre>
<p>Include the main PHP_CompatInfo file, set the path to the file or directory you want to check and then just run it. By default it&#8217;ll just var_dump the results, which is pretty much OK for a few files and directories. For a library like Zend Framework, I found the XML output to be the best. Besides the var_dumping and XML, there are other options for the output like CSV, a simple HTML table and Text, which is used when using the CLI. Oh, right, you can run it either from the console or from your web browser. <a href="http://pear.php.net/manual/en/package.php.php-compatinfo.tutorial.php">PHP_CompatInfo&#8217;s documentation</a> is very well written and describes all part of it, so I won&#8217;t be bugging you with that.</p>
<p>So yea, this little gem goes right into my box of must have tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/a-real-gem-php_compatinfo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ape is a PHP editor</title>
		<link>http://robertbasic.com/blog/ape-is-a-php-editor/</link>
		<comments>http://robertbasic.com/blog/ape-is-a-php-editor/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 21:42:58 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ape]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pyqt]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=933</guid>
		<description><![CDATA[A week ago I started working on a simple editor/IDE for PHP called ape. That&#8217;s my weak try on creating a reverse acronym as ape stands for &#8211; ape is a PHP editor. This is kind of an introductory post into the whole developing process of it, as my intention is to blog about it [...]]]></description>
			<content:encoded><![CDATA[<p>A week ago I started working on a simple editor/<a class="zem_slink" title="Integrated development environment" rel="wikipedia" href="http://en.wikipedia.org/wiki/Integrated_development_environment">IDE</a> for <a class="zem_slink" title="PHP" rel="homepage" href="http://www.php.net/">PHP</a> called ape. That&#8217;s my weak try on creating a <a class="zem_slink" title="Backronym" rel="wikipedia" href="http://en.wikipedia.org/wiki/Backronym">reverse acronym</a> as ape stands for &#8211; <strong>a</strong>pe is a <strong>P</strong>HP <strong>e</strong>ditor. This is kind of an introductory post into the whole developing process of it, as my intention is to blog about it a bit more :)</p>
<h3>Why?</h3>
<p>First, to answer the question everyone is giving me when I mention I&#8217;m writing ape:<br />
<em>&#8220;Why the hell do you do that (to yourself)?&#8221;</em></p>
<p>Programming is fun. Programming is interesting. Programming makes me learn new things. I like having fun and I do this to learn more about programming and having even more fun. I&#8217;m writing web applications each and every day, so writing a desktop app requires a different way of thinking and leaving my &#8220;comfort zone&#8221; (altho, I&#8217;m quite comfortable in front of the keyboard hackin&#8217; away code). ape is written in python and pyqt, but again, it&#8217;s not about the language used, for me <strong>it is about programming</strong>.</p>
<h3>The idea</h3>
<p><a class="zem_slink" title="NetBeans" rel="homepage" href="http://www.netbeans.org/">Netbeans</a> is my main IDE for quite some time now and I love it. I know my way around vim, too. But, netbeans has too many features for my taste &#8211; I use <a class="zem_slink" title="Apache Subversion" rel="homepage" href="http://subversion.apache.org/">SVN</a>, git, (on rare occasions I write them) run unit tests from the console. As for vim, maybe I just don&#8217;t get it enough, but I feel less productive with it. Debugging PHP apps ends up var_dump-ing things all over the place. So, basically what I want/need from an editor is grouping files into projects, regex search/replace, code coloring &amp; completion and, of course, file editing.</p>
<p>I plan to write a feature a day. On my personal projects I usually want to push out as much code as I can during one day as I&#8217;m highly motivated, but this time want to try a different approach. So far I didn&#8217;t got far, figured out syntax highlighting, opening files from a file browser widget thingy and things like that, but more on that in other posts.</p>
<p>If anyone wants to take a look, the source code is up on <a href="https://github.com/robertbasic/ape">github</a>. It is licensed under GNU <a class="zem_slink" title="GNU General Public License" rel="wikipedia" href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL v2</a>, as pyqt is licensed under it and I don&#8217;t want to waste my time on figuring out could I use MIT or some other license.</p>
<p>Happy hackin&#8217;!</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/zemified_e.png?x-id=10fafb1b-6597-4351-b0e3-964bcc98b601" alt="Enhanced by Zemanta" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/ape-is-a-php-editor/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>A regional PHP community website</title>
		<link>http://robertbasic.com/blog/a-regional-php-community-website/</link>
		<comments>http://robertbasic.com/blog/a-regional-php-community-website/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 20:29:35 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Places on the web]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpplaneta]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=924</guid>
		<description><![CDATA[This week on Wednesday, finally one of my pet projects has hit the Internets! PHPPlaneta.net is alive! It&#8217;s idea is to be a community website for PHP programmers from Serbia and other countries from the region. The idea for this website &#8220;hit&#8221; me somewhere in April or May I think, while I was lurking the [...]]]></description>
			<content:encoded><![CDATA[<p>This week on Wednesday, finally one of my pet projects has hit the Internets! <a href="http://phpplaneta.net/">PHPPlaneta.net</a> is alive!</p>
<p>It&#8217;s idea is to be a community website for PHP programmers from Serbia and other countries from the region. The idea for this website &#8220;hit&#8221; me somewhere in April or May I think, while I was lurking the interwebs for some, any PHP communities in the region, user groups, anything really, where local PHP programmers could share ideas, news, interests, etc., but found nothing (well, besides 2 bulletin boards and a few of us on Twitter). So, I decided to try and create one.</p>
<p>Of course, this website is only the first step. The purpose of this website is to share news, articles and whatnot with other programmers, something like Mr. Cornutt does on <a href="http://phpdeveloper.org/">phpdeveloper.org</a> ;) There&#8217;s not much up there yet, but that&#8217;ll change soon :) Altho the functionality of the website is pretty simple and I could&#8217;ve put it out in like 2 hours with wordpress, I wrote it from scratch (using Zend Framework of course!), just, well, because I can :D Once I tidy up the code and maybe refactor here and there, it&#8217;ll be up on github (multiple reasons for putting it up there, but that&#8217;s for some other post).</p>
<p>I have other ideas for the future, both online and offline related, but first want to put this website on it&#8217;s feet.</p>
<p>So, here&#8217;s to a better and brighter future for PHP communities around here!</p>
<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/a-regional-php-community-website/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Loading custom module plugins</title>
		<link>http://robertbasic.com/blog/loading-custom-module-plugins/</link>
		<comments>http://robertbasic.com/blog/loading-custom-module-plugins/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 12:24:28 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[loading]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://robertbasic.com/blog/?p=915</guid>
		<description><![CDATA[OK, here&#8217;s a quicky one from the office :P I was trying to load a Front Controller plugin which resides in app/modules/my_module/controllers/plugins/ and not in the &#8220;usual&#8221; lib/My_App/Plugin/. I want this plugin to be called in every request and I want the plugin file to be under it&#8217;s &#8220;parent&#8221; module. Here&#8217;s what I did: added [...]]]></description>
			<content:encoded><![CDATA[<p>OK, here&#8217;s a quicky one from the office :P</p>
<p>I was trying to load a Front Controller plugin which resides in <code>app/modules/my_module/controllers/plugins/</code> and not in the &#8220;usual&#8221; <code>lib/My_App/Plugin/</code>. I want this plugin to be called in every request and I want the plugin file to be under it&#8217;s &#8220;parent&#8221; module.</p>
<p>Here&#8217;s what I did: added the path to the plugin and it&#8217;s namespace to the Zend_Application_Module_Autoloader as a new resource type and then just register the plugin in the front controller in an other _init method.</p>
<p>Code is better, here&#8217;s some:</p>
<pre class="php" name="code">class News_Bootstrap extends Zend_Application_Module_Bootstrap
{
    /**
     * Autoloader for the "news" module
     *
     * @return Zend_Application_Module_Autoloader
     */
    public function _initNewsAutoload()
    {
        $moduleLoader = new Zend_Application_Module_Autoloader(
                                array(
                                    'namespace' =&gt; 'News',
                                    'basePath' =&gt; APPLICATION_PATH . '/modules/news'
                                )
                            );

        // adding model resources to the autoloader
        $moduleLoader-&gt;addResourceTypes(
                array(
                    'plugins' =&gt; array(
                        'path' =&gt; 'controllers/plugins',
                        'namespace' =&gt; 'Controller_Plugin'
                    )
                )
            );

        return $moduleLoader;
    }

    public function _initPlugins()
    {
        $this-&gt;bootstrap('frontcontroller');
        $fc = $this-&gt;getResource('frontcontroller');

        $fc-&gt;registerPlugin(new News_Controller_Plugin_Scheduler());
    }
}
</pre>
<p>If anyone knows a better way for doing this, please do share it with me.</p>
<p>Now back to work. Cheerio.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertbasic.com/blog/loading-custom-module-plugins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

