Category: Programming

  • Working zero config php xdebug 3.1.1 and phpStorm 2021.3 RC

    php 7.4 w/xdebug 3.0

    phpStorm 2020.3

    zend_extension=”xdebug.so”
    xdebug.mode=debug;
    xdebug.file_link_format=”http://localhost:63342/api/file/%f:%l”

    This now makes xdebug output links that open phpstorm (which is actively listening on port 63342… phpstorm:// wasn’t working for me anymore…

    [UPDATE 2021-01-14]
    zend_extension="xdebug.so"
    xdebug.mode=debug;
    xdebug.file_link_format="phpstorm://open?file=%f&line=%l

    phpStorm 2020.3.1
    php 8.0.1
    xdebug 3.0.1

    [UPDATE 2021-11-29]

    Seems like phpstorm/intelliJ have changed the mechanism, and phpstorm:// protocol no longer works.

    After much troubleshooting I have it working, but for projects that use a framework, such as Symfony.

    You will now need to utilize the framework.yml ide field,

    https://symfony.com/doc/current/reference/configuration/framework.html#ide

    and enter it as follows:

    • phostorm 2021.3 RC
    • PHP 8.1.0
    • xdebug 3.1.1
    1. Comment out the xdebug.file_link_format, as that no longer works…
    2. edit: /config/packages/framework.yaml
    framework:
        ide: 'jetbrains://php-storm/navigate/reference?project=%env(resolve:PROJECT_NAME)%&path=%%f:%%l'

    3. edit: /.env ensure that this matches your project name… otherwise jetbrains won’t be able to find the correct session/window.

    PROJECT_NAME="the name of the project"

    4. clear cache, and now your links should work.

    5. restart apache/nginx if required.

    Now your Symfony project will allow you to edit your files again.

    [Update: 2023-07-12]

    No need for PROJECT_NAME again, or the edit to the framework.yaml file
    1. edit your php.ini file, (or xdebug.ini), to include the line

    xdebug.file_link_format="phpstorm://open?file=%f&line=%l"

    2. restart apache/nginx/php-fpm if required.

  • Mac OSx High Sierra Homebrew switching between [email protected] and [email protected]

    Homebrew recently deprecated the repo https://github.com/Homebrew/homebrew-php as of March 31st, 2018.
    So, how do you install [email protected], and/or [email protected] (or @7.0, or @7.1, these are untested, but I assume will work).
    I work on some legacy sites, that require switching between the versions.
     
    So, lets run through this… I’m going to assume you cleaned up the old version of PHP.

    # clean up the old PHPs.
    $> brew uninstall uninstall php72 php56

    # append whatever options you may want. maybe –with-httpd
    $> brew install [email protected]
    $> brew unlink [email protected] –force
    $> brew install [email protected]
    $> brew unlink [email protected] –force
     
    modify you’re httpd conf, to accept your desired version of PHP you want to run.
    /usr/local/etc/httpd/httpd.conf

    #LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
    LoadModule php5_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp5.so

    If you run
    $> php -v
    it will fail.
    $> php -v
    -bash: /usr/local/bin/php: No such file or directory

    This is because we unlinked both versions.
    Say we want to use PHP version 5.6
    $> brew link [email protected] --force
    Now when we php 5.6 as our cli PHP.
    $> php -v
    PHP 5.6.35 (cli) (built: Mar 31 2018 20:21:31)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

    If you want php5 to run in apache.
    ensure that php5 module is enabled in httpd.conf, and restart apache/httpd deamon.
    $> sudo brew services httpd restart
    NOTE: You need to run with sudo, if your http port is below 1000, or was that 1024… I forget.
     
     
    If you want to switch back to [email protected],

    1. unlink,
    2. change httpd.conf to use php7.2
    3. restart apache

     
     
    Also, if you want to install xdebug,or memcached use pecl.
    for [email protected]
    $> pecl install xdebug-2.2.0
    for [email protected]
    $> pecl install xdebug
     
    If you want memcached:
    with [email protected] (as of writing this, 2018-04-10)
    brew install libmemcached
    brew install pkg-config<
    pecl install memcached-2.2.0

    use: /usr/local/Cellar/libmemcached/1.0.18_2 for the memcached location.

  • Automation…

    Controllers:
    Raspberry PI for the logic. it’ll have it’s own 802.11n USB adapter
     
    Project Ideas:
    The promise, is to use an ESP8266, to control a bunch of relays.  Using the Raspberry PI for logic control.

    1. DIY 1 plug relay – HRV control.
      1. Check to see (via the NEST) if the humidity is high or low, run the HRV
      2. Intermittent running of HRV when
        1. Run HRV if not during peak/high energy rates…
    2. DIY 8 plug power bar, timer on/off control.
      1. Build your own power bar, that is WIFI controlled.
      2. ESP8266 has several GPIO pins.  Wire them up to relays, to get some relay action going.
        1. Printer on demand.
        2. Scanner on demand.
        3. VPN hardware on during weekdays work hours.
        4. Monitors (5watts on standby).
        5. USB power on standby.
        6. Thunderbolt belkin on standby when not in use.
        7. USB External HDs???
    3. DIY 8 plug power bar, timer on/off control.
      1. TV
      2. Set top box
      3. blue-ray player
      4. PS4/XBOX etc…

     

  • Debugging a segfault in PHP

    debugging segfaults is not fun.
    My low key technique:

    1. place a printf(“made it here: %s, %s+ %sn”, __METHOD__, __LINE__, __FILE__); everywhere…
    2. put “DIE(‘something’);” to figure out the exact line that fails.  If dies, good.  move it further down.  If it segfaults, move the die statement up.  Until you’ve found the exact line that fails.
    3. Figure out why it’s segfaulting…  uh… good luck with that.  Google, and look at the changelog in PHP to see if it’s been fixed.

    An easier option, if I were the one controlling the box — Update to the latest PHP.

  • little project ideas

    Just found a need to access my home server… however, it’s powered down… how can I overcome this problem in the future.  To answer my own question…  I should go lookup how to send a wake-on-lan command to the box. As well as know what my IP is…
    project ideas:
    1.) Current IP notifier – send to my webserver, what my home server IP is. (Dynamic). I could use a dynamic dns service… this maybe interesting to learn how to do this, if I have my own VPS… have the home-server, notify the web-server to update the DNS setting. So I would have something like: homelan.lloydleung.com or whatever.
    2.) wake on lan commands.
    3.) vpn to the network instead… with a combo on 1. This way, everything is encrypted…

  • My current extension list for firefox 3.0.1

  • ajax form submits problem

    yesterday was a few hours of frustration.
    Make sure your your <form> tag is within the same <td> cell element.  Otherwise it’s not XML compliant.
    You can have the form outside the <table> — but not between it, and a <td> element.

  • Gallery is fixed.

    My old gallery is fixed now…
    debating on writing a new gallery, or make a plugin for wordpress to have a gallery.
    How the plugin would work…
    1.) Create a keyword, to enable the gallery.
    2.) grab uploaded files, that are images via mime type, and display them.
    3.) display the images via lightbox2, or something else that’d be suitable.
    4.) Get titles, and descriptions for files
    Pretty handy utility, not much else needed. All the hard parts are already handled by WP.

  • Ubuntu + Mysql setup

    Wow, that was so painless.
    Original Post
    Use your favourite means to install mysql, probably apache, php, phpmysqladmin as well…

    sudo /etc/init.d/mysql start
    mysqladmin -u root password myPassword

    where myPassword is your actual password.
    to test
    mysql -u root -p
    enjoy

  • PEAR::DB_DataObject_FormBuilder howto

    Wow, I refactored my calendar web app and used PEAR::DB_DataObject_FormBuilder to make the backend.
    One thing I have to admit, the documentation for certain PEAR applications lacks dearly. Just like all OSS packages. It’s just the nature of things.
    The personal support I recieved from irc://efnet.org/pear was great. After a little guidance, the members in that chat channel were able to help me out. After my refactoring, I decided to write a basic howto. (more…)