Example application

  • Hello,


    I'd like to know if there's a difference between

    PHP: global.php
    <?php
    // include config
    require_once(dirname(__FILE__).'/config.inc.php');
    // include wcf
    require_once(RELATIVE_WCF_DIR.'global.php');

    and

    PHP: global.php
    <?php
    // include config
    require_once(__DIR__.'/config.inc.php');
    // include wcf
    require_once(RELATIVE_WCF_DIR.'global.php');

    I'm trying to understand the packages for the WCF. My only knowledge of PHP comes from a very basic 4-hours course at Codecademy. I found a link in German which shows how to do an example app for the WCF and I'm trying to reproduce it (Thank you Google Translate!).


    I'm using PhpStorm 10 (php 5.6) and since I'm not a programmer I guess it's a good idea to follow IDE's suggestions (it knows PHP better than me || ). The IDE suggest me to use __DIR__ instead of dirname(__FILE__) but looking at some applications I have downloaded they all have dirname(__FILE__). The php documentation says they both are equivalent, but why does WoltLab and WCF developers prefer to use one instead of the other?




    Thanks in advance for your help.



    P.S. : I wish there were better documentation for the WCF ;(

    My styles and plugins in the Plugin-Store.

    ♪Quiero robarle los minutos a las horas pa' que mis padres nunca se me pongan viejos...♫

    • Official Post

    The PHP code for the global.php is still the same since WCF 1 which was released back in 2007 and required PHP 5.0.3. The constant __DIR__ was first added with PHP 5.3 and has the same exact effect as using dirname(__FILE__). Both are valid and yield the same result, therefore it doesn't really matter which one you actually use.

    Alexander Ebert
    Senior Developer WoltLab® GmbH

  • Thank you @Alexander Ebert.


    I'm not sure Google does a good translation of the tutorial I'm following and additionally, I don't even know if it will be compatible with WCF 2.1, so I don't know if I'm wasting my time :/


    I know WoltLab is not a big company with hundreds of employees, and developers in general (not just from WoltLab) tend to procrastinate the writing of documentation, or not write it at all, but it would be very nice and useful if you (WoltLab) do a tutorial about how to create a simple application and simple plugins such as bbcodes, smilies, etc. :whistling:


    For non programmers is very hard just to look at the code and understand it, and the "Wiki" of the WCF on GitHub is primary intended for developers, outdated, and incomplete. I do love WBB and the WCF but the lack of proper documentation is very frustrating :( ;(

    My styles and plugins in the Plugin-Store.

    ♪Quiero robarle los minutos a las horas pa' que mis padres nunca se me pongan viejos...♫

  • For non programmers is very hard just to look at the code and understand it

    It's not made for non programmers. This task is for devs. Plugins and especially applications need a higher level of object oriented programming if it should be done right.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!