MW

Tag php - page 3

Recent Posts

KDevelop Hack Sprint 2009 - Day 2 and 3 (April 23, 2009)

Ok, just a quick update on what we are doing / have done the last two days except drinking beer and eating quite a lot of food (though it never seems to be enough somehow….)

  • Apol was polishing CMake support, speeding up KDevelop startup time when you enabled the QtHelp plugin, making sure that Kross plugins get loaded properly and some other things
  • Adymo started some refactoring of Sublime in an experimental branch (actually they had quite a long discussion right now about things in the UI which should be changed/fixed). Besides that he also fixed some little bugs in the includepath resolver for CMake
  • Nsams is fixing PHP support and adding new features here and there. Esp. completion inside a foreach over a Iterator class works now!
  • and as always ZWabel did fix quite a lot of bugs, most of them which only were discoverable in a few corner cases, very nice indeed.
  • shaforo who sadly already left us again to attend university fixed the sorting in the Project view among other things
  • With Apols help I managed to get started with a documentation plugin which (currently) integrates PHP.net. I plan to make it possible to use the downloadable PHP.net documentation as well to speed things up. Actually setting up a documentation plugin is very easy! Maybe I’ll take a look at writing a documentation plugin for Zend, Symfony, etc. pp. as well - should be fairly easy. Maybe I can come up with a generic documentation plugin which makes it possible to include any kind of .html documentation with some configurable mapping… lets see! Or maybe I should take a look at writing Kross plugins (Apol could help me here as well) for that purpose.

continue reading...

KDevelop Hack Sprint 2009 - Day 1 (April 20, 2009)

Ok, a short blog about the first day of our KDevelop Hack Sprint at Mykolayiv (see my first blog post). First up, being in the Ukraine is a very interesting experience since it’s totally different from any place I have ever been to. And thanks to the great hospitality of Alexander (adymo) we already had a city tour of Odessa and Mykolayiv.

Tomorrow will be the first real day of our hack sprint: Today we only hacked at our flat for a few hours. Before that we had the city tour through Mykolayiv. And tomorrow David Nolden (zwabel) and Nick Shaforostoff will arrive which will make the list complete.

Today I personally worked on making KDevelop support dark color schemes better which is still a work in progress (nothing comitted so far). Actually for a real good experience I’ll have to extend KTextEditor to make it’s color configuration available for the parent application (i.e. KDevelop). Let’s see when I get to that. Though I plan to push my patches to KDevplatform beforehand for an intermediate solution.

continue reading...

KDevelop Hack Sprint (April 02, 2009)

Huzza! The KDevelop Hack Sprint 09 is now official.

Thanks to the huge engagement of Alexander Dymo we will meet from the 19th to 26th April 2009. The meeting will take place at Alexander’s university, the national university of shipbuilding in Odessa Mykolayiv, Ukraine. Thanks to the people there responsible for making this sprint possible by providing us with the premises, internet, power etc.

Since this is my very first Hack Sprint and considering that I only recently started contributing to KDE in general and KDevelop in particular I am very excited. The topics I will plan to hack on include (all related to PHP language support plugin):

  • add auto completion after require(_once) and include(_once), just like it works for #include in CPP
  • add auto completion of PHP statements (think echo, exit, require(_once, include(_once) etc. pp.)
  • add auto completion for build-in PHP keywords
  • fix auto completion of interfaces / classes after the keywords implements and extends (working on that right now)
  • fix KDevplatform and the Generic Plugin Manager to support remote projects, i.e. via fish or ftp (or anything else supported by KIO)

continue reading...

Building KDevplatform, KDevelop and the PHP plugin from Git (March 06, 2009)

In a follow up to my last post about the PHP plugin for KDevelop and Quanta I want to detail how I setup my build environment. Since I’m only working on KDevelop I only want to compile that. For all other applications, I use the packages my distribution makes available. Below you this is possible.

Note: I use Kubuntu and hence some commands like aptitude and the package names etc. will have to be adapted to your specific distribution. But the general idea should be the same and the packages should be called at least somewhat similar. You could always take a look at the techbase article on compilation of KDE 4 to get a more general HowTo.

It is generally a very good idea to read some articles on the techbase. Especially in the Getting Started section.

getting the dependencies

First, you’ll need to install some packages to satisfy dependencies and to get a working compile chain (think cmake, gcc and stuff). The following command only lists very few packages but they have a huge list of dependencies which your package manager will take into account automatically. Don’t be suprised by a possibly huge list of packages ;-) So some disk space will be required (though I doubt it’s more than 250MB in total).

continue reading...

Building KDevplatform, KDevelop and the PHP plugin from Git (March 06, 2009)

In a follow up to my last post about the PHP plugin for KDevelop and Quanta I want to detail how I setup my build environment. Since I’m only working on KDevelop I only want to compile that. For all other applications, I use the packages my distribution makes available. Below you this is possible.

Note: I use Kubuntu and hence some commands like aptitude and the package names etc. will have to be adapted to your specific distribution. But the general idea should be the same and the packages should be called at least somewhat similar. You could always take a look at the techbase article on compilation of KDE 4 to get a more general HowTo.

It is generally a very good idea to read some articles on the techbase. Especially in the Getting Started section.

getting the dependencies

First, you’ll need to install some packages to satisfy dependencies and to get a working compile chain (think cmake, gcc and stuff). The following command only lists very few packages but they have a huge list of dependencies which your package manager will take into account automatically. Don’t be suprised by a possibly huge list of packages ;-) So some disk space will be required (though I doubt it’s more than 250MB in total).

continue reading...

PHP support for KDevelop 4 (and eventually Quanta+) (March 03, 2009)

Hello Planet KDE!

I want to give you a little insight on the current state of PHP support in KDevelop4:

Me and Nikolaus Sams (nsams) are working diligently on a plugin for PHP support in playground. It’s somewhat stable, i.e. we fix any crashes we stumble upon, but I would call it Alpha state at most. It may eat your babies so to speak. Yet I’m happy to say that at least one user is already using it for production (hi leinir ;-) ).

implemented PHP support

Well, here’s a (not complete) list of features that are already working. Though I have to warn you: no screenshots included ;-) It’s actually all very similar to the C++ screenies you can see on the web.

sematic highlighting

Let’s start with a feature that only very recently was added for PHP - semantic highlighting. Niko moved some language independent parts of the C++ plugin from KDevelop to KDevplatform and now PHP has the same code highlighting features as C++.

continue reading...

PHP "is_whitespace" performance (February 12, 2009)

Easy question: What is the fastest way to determine if a string in PHP is whitespace-only?

Easy answer: ![preg_match](http://www.php.net/preg_match)('[^\s]', $string);

Read on for the explanation:

I applied the codeblocks feature of my profile.class.php, here’s the testcase:

    <?php
    require 'profile.class.php';
     
    $iterations = 10000;
     
    profile::codeblocks(array(
      'trim(long string) == ""' => 'trim($long) == ""',
      'trim(long string) === ""' => 'trim($long) === ""',
      'rtrim(long string) == ""' => 'rtrim($long) == ""',
      'rtrim(long string) === ""' => 'rtrim($long) === ""',
      'ltrim(long string) == ""' => 'ltrim($long) == ""',
      'ltrim(long string) === ""' => 'ltrim($long) === ""',
      '!preg_match("[^\s]", long string)' => '!preg_match("[^\s]", $long)',
      'ctype_space(long string)' => 'ctype_space($long)',
      'trim(short string) == ""' => 'trim($short) == ""',
      'trim(short string) === ""' => 'trim($short) === ""',
      'rtrim(short string) == ""' => 'rtrim($short) == ""',
      'rtrim(short string) === ""' => 'rtrim($short) === ""',
      'ltrim(short string) == ""' => 'ltrim($short) == ""',
      'ltrim(short string) === ""' => 'ltrim($short) === ""',
      '!preg_match("[^\s]", short string)' => '!preg_match("[^\s]", $short)',
      'ctype_space(short string)' => 'ctype_space($short)',
    ), array(
      'long' => str_repeat(" \n\t ", 500) . "a" . str_repeat(" \n\t ", 500),
      'short' => str_repeat(" \n\t ", 5) . "a" . str_repeat(" \n\t ", 5),
    ), $iterations);
     
    profile::print_results(profile::flush());

continue reading...

profile.class.php (June 24, 2008)

Every now and then I want to profile a given part of PHP code. For example I want to quickly check wether my current changeset to GeSHi works faster or is horribly slower. For a big change I’ll stick to Xdebug and KCachegrind. But for a quick overview? Overkill in my eyes.

Say hello to profile.class.php, a simple timer class for PHP5 which you can use to get an overview about where how much time is spent. This is in no way a scientific method nor should you take the results of a single run as a basis for you decisions.

I’ve set an emphasize on an easy API so you don’t have to pollute your code with arbitrary hoops and whistles.

UPDATE: You can find the current updated source in the SVN repo of GeSHi.

Simple example

This is a quick example on how you could use the class:

    <?php
    require 'profile.class.php'; // should be obvious ;-)
     
    // here might be uninteresting code
     
    profile::start('overall'); // start a timer and give it a name
                                       // we add this one to get a time
                                       // for the overall runtime
     
    // this is the code you want to profile
    profile::start('$_SERVER');
    $foo = count($_SERVER);
    profile::stop(); // stop the last active counter
     
    profile::start('$GLOBALS');
    $bar = count($GLOBALS);
    profile::stop();
     
     
    profile::stop(); // stop overall timer
    profile::print_results(profile::flush()); // print the results

continue reading...

recent GeSHi contributions (apache, xorg, apt, performance, ...) (June 18, 2008)

Your favourite syntax highlighter for web applications, GeSHi, recently got some new features and bug fixes. By yours sincerely. A rough summary of what I contributed:

  • various performance improvements, i.e. some speed optimizations and reduced memory consumptions (especially peak memory usage is down by roughly 1MB when highlighting geshi.php by itself)
  • minor bugfixes, including one which prevents some nasty PHP notices on PHP 5 systems to contaminate your precious log files
  • improved language files: bash, apache
  • added language files: GNU Gettext, Xorg configuration and Apt sources.list

Some of those features were already shipped with the recent 1.0.7.22 release. But the two new language files and the improvements to the existing apache language file are currently only available via SVN. Wait for the next stable release which should be 1.0.8.

continue reading...

Drupal modules and other configuration (June 11, 2008)

Drupal is such a pleasing piece of software.

Just a few days ago I found some very cool new (to me) hidden functionality. Additionally I’ve installed some more modules which I want others to be aware of.

available updates email notification

Let’s start with the “hidden” functionality: Drupal 6 incorporates some parts of a Drupal 5 module which notifies you about available updates (see /admin/reports/updates). Pretty easy to stay updated with that alone. But I thought I’d had to check that page frequently for new updates. Not so! Say hello to the tab “Settings” on the very page and insert your email address to stay updated via email. Satisfying and built-in… dumb me searches in vain for a module with that functionality…

Yet it brought my interest to other useful modules:

Logging and alerts

The Logging and alerts module gives you a way to send emails to an email address of your choice in case of errors etc. Pretty neat since I don’t want to lose time by regularly scanning my log entries…

continue reading...