Drug preguntas

How to parse the phpdoc

PHP No Comments »

your goal: you created some new annotations into the phphdoc and you’d like to retrieve these information. So you are looking for a PHPdoc parser.
Get the Zend Framework. Note that the Zend Server component should probably be enough. Here some code to use it:

/// load the Zend Framework – You’ll probably need to change these two lines
require_once “Zend/Loader.php”;
Zend_Loader::registerAutoload();

/// I load my personal library class
require_once(library.php);

/// The magic Reflection class is going to do the work for you – Here I load my personal class named “library”
$reflection = Zend_Server_Reflection::reflectClass(“library”);

/// We’re going to retrieve the docblocks of the library class functions
foreach($reflection->getMethods() as $method){
$docBlock = $method->getDocComment(); //here we retrieve the docblock of a class function
/// then I’m parsing the docblock, modify the regular expression in order to retrieve your own phpdoc annotation
preg_match_all(‘/\s*\*\s*@(subparam|subreturn)\s+(\w+)\s+(\$\w+(?::\w+|->\w+)+)((?:\s+(?:optional|required|multiple))*)/’, $docBlock, $matches);

/// test display to see what we get
echo “<pre>”;
var_dump($method->getName());
var_dump($matches);
echo “</pre>”;
}

Two simple things to make your day

Thoughts No Comments »

* Put mini-pictures of your family and friends on your fridge door.
* Write a list of last year achievement and a list of goals for this year.

Victoria bushfires

Thoughts No Comments »

redcross

allburned

For the two last days, the bushfires have been worst in the Victoria state. Firemen do not know how long it will take to stop the different fires. More than one hundred people have died in these bushfires. If you like to help, you can make a donation to the red cross.

truck

vache

firedcar

fireman

Pictures from Lemonde.fr (french)

Netbeans, the IDE for PHP

PHP No Comments »

Ok make it clear, I love Netbeans. It’s all in the box with a ultra easy installation and a transparent update system. It does what you expect from a commercial IDE, and it’s free. So if you do program in PHP, I invite you to try it.

My first Netbeans, the version 3

I started with Netbeans 3 for the i18n Java function.

Spotify, free music

Music No Comments »

The last music software starting to be popular is Spotify. It is really similar to itunes. Same design, great catalog, but that is free. It’s at this moment only available for UK, Spain and France. In order to subscribe you need to go on this web page
If you are from another country you can try to go to this link through a open proxy

spotify_desktop_client

They’ve got almost all big majors, and they dispatch some ads times to times. Even if I didn’t hear any ads yet. There should be a 10 euros version without ads, which in my opinion really worth it if the catalog continues to growth. The best, it works like a charm with Wine on Ubuntu.

Really short Zend XML-RPC client/server

Moodle, PHP No Comments »

A really short XMLRPC client/server using Zend framework. I let you change your include/require. The require lines used here work for Moodle.

Server.php

[php]///require-include TODO: change these lines for your project
require_once(dirname(__FILE__) . ‘/../../config.php’);
include ‘Zend/Loader.php’;
Zend_Loader::registerAutoload();

///the server
$server = new Zend_XmlRpc_Server();
$server->setClass(‘xmlrpc_authentication’, ‘authentication’); //second parameter is the spacename for xmlrpc
echo $server->handle(); //don’t forget echo

class xmlrpc_authentication {

/**
* following the ‘struct’ is the important doctype, but
* you can still use the | notation if you need to define another type
* @param array|struct $params
* @return integer
*/
function get_token($params) {
if ($params['username'] == ‘wsuser’ &amp;&amp; $params['password'] == ‘wspassword’) {
return 465465465468468464;
} else {
return 0;
}
}
}
[/php]

Client.php

[php]
///require-include TODO: change these lines for your project
require_once(‘../../../config.php’);
include ‘Zend/Loader.php’;
Zend_Loader::registerAutoload();

$client = new Zend_XmlRpc_Client(‘http://your_project_url/server.php’);
//Note: arguments (here it’s an associative array) are into an array
echo ‘token (call) is : ‘ . $client->call(‘authentication.get_token’, array(array(‘username’ == ‘wsuser’, ‘password’ ==’wspassword’)));
[/php]

Theme by NattyWP