Posts Tagged: PHP


8
Jan 10

Class Aliases

I’ve been very busy lately, for example with the first release of Mai Ocean, that it was hard to find time for writing posts. :( Of course I had to give some sign of life! Therefore I am filling this first post of the year with a great function I recently found.

When writing the handler system for Mai Ocean I had to find a way to access a static class that had a variable name. Accidentally I found the new class_alias() function on php.net. This function gives you the ability to easily create a alias for any class. Usage is simple:

class_alias('New', 'Original');

The function is available in version 5.3 and above and works with namespaces. In Mai Ocean I just use the following:

$handler = 'MaiOcean\UserHandler\\' . $this->config()->handlers->name;
 
class_alias($handler, 'MaiOcean\UserHandler\Handler');

Now I can just use my new name instead of a variable! How great is that? :D

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

9
Dec 09

Multiprocessing part 1: Quick & Dirty

DEC Alpha AXP 21064 microprocessor

DEC Alpha AXP 21064 microprocessor

PHP can do only one thing at a time. Usually (for websites) this isn’t a big problem because you only have to process a request. On the other hand, if you are doing something more time-consuming PHP could be to slow.

An example is my chat bot server (Mai Ocean). For each conversation I have to make a connection with a server, so for each conversation I have a socket that I have to listen and write to. So if 10 people are talking to my bot I have at least 11 socket connections (10 conversations + main server), you could imagine that this would be way to much for just one script. So how can we solve this? Continue reading →

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

5
Dec 09

PHP, Hell or Heaven: Documentation

Hell or Heaven?

Hell or Heaven?

A programming language can be great but if you do not know how it works then it’s (practically) worthless. In general you can say that the documentation is a important part of a programming language. Returning to this series, we can only tag PHP as “Heaven” if it has a good documentation. Now that’s the question we should answer today.

If you have used PHP before you should already now the answer to this question. It is definitely yes. I have never heard someone saying that the documentation was bad or somehow not good enough. Even people who hate PHP can’t disprove that (of course they could try). Continue reading →

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

2
Dec 09

PHP, #3 Most popular programming language

The comany TIOBE collects statistics about the popularity of programming languages. In their last analysis PHP was on position 3 and that is something to be proud of. :) The only two that are popular than PHP are C and Java. PHP is also in the race for “Programming Language of 2009″ together with C and C#!

The development in the rankings can be found in the graph below:

Long term trends for the top 10 programming languages

Long term trends for the top 10 programming languages

The total ranking list can be seen on the TIOBE website.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

1
Dec 09

The bootstrap: Germination of your application

Sunflower seedlings

Sunflower seedlings

After the start of your (PHP) application it will grow. You will include more and more files, execute more functions and handle more data. When you are finished processing, all memory will be released and your app will ‘die’. Summarized you could represent your application as something simple like a plant!

The first part of “it’s life” is germination, your application has to start and set up everything he needs. In more technical terms you can call this term the bootstrap. If you use a framework such as Zend Framework you’ve probably already heard from it. Using a .htacess file you direct all traffic to your bootstrap that then will startup the main application. For a person like I (who creates PHP CLI apps) the bootstrap is a way of setting important environment variables. So what should a bootstrap do? Continue reading →

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

29
Nov 09

Interesting topics

When I started this blog I already had some topics on my mind and tonight I thought “Why not put them online?” so that’s exactly what I did. Below I have written down some interesting topics I like and want to write about in the forthcoming days/weeks.

  1. Bootstraps (already working on this)
  2. Compiling PHP (an idea by Jasper)
  3. More “PHP, Hell or Heaven?”
  4. Running multiple PHP scripts at once (and let them communicate!)
  5. eZ Components (especially the Console Tools)
  6. Text analysis with PHP

(You may have noticed that I copied some from the Mai Ocean introduction post.)

When I was writing this I also came up with some questions: What do you think about these topics? Which do you prefer and do you have anything to add? Especially for the series “PHP, Hell or Heaven?” I would like to know what you like about PHP and (maybe even more) what you hate. Thus for all people out there that hate (or dislike) PHP: This is your time to speak! ;)

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

27
Nov 09

PHP, Hell or Heaven: Data types

Hell or Heaven?

Hell or Heaven?

This is the first post of the new series “PHP, Hell or Heaven?”. Today I’m going to talk about data types in PHP and compare their usage with other languages.

In PHP there are multiple data types but the main difference between other languages (especially more low level languages such as C++) is that you can assign any value to any variable. This is also called type juggling. Therefore in PHP the type of an variable is defined by its content and not by the developer or by the way it’s been set-up. Continue reading →

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

25
Nov 09

Unit testing in PHP

Unit testing with PHPUnit

Unit testing with PHPUnit

‘Everyone’ says unit testing is important. If I quote Wikipedia you should under stand why:

In computer programming, unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use.

Continue reading →

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

24
Nov 09

Assertions, protection against yourself

When I write new code (especially objects) I tend to build in extra security measures to protect the code against myself or other developers. Please note that I do not mean users but only the people who use the code. Continue reading →

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS

23
Nov 09

Mai Ocean, a PHP bot server

Mai Ocean Logo

Mai Ocean Logo

Besides studying and living I like to work on my Open Source project Mai. Mai is a project that consists of several sub projects and one in particular, Mai Ocean, I want to discuss here. It is currently my focus of development because it is an vital part of the Mai Project.

So what is Mai Ocean exactly? In a few words you could say that it is a bot server written in PHP. Of course this doesn’t say much so let me explain further. Continue reading →

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Hyves
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • PDF
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Add to favorites
  • NuJIJ
  • RSS