Monday, February 25, 2013

Create desktop icon for PhpStorm in Ubuntu

It's very simple to create desktop icon, or unity launcher.  Run PhpStorm, click to "Tools", then "Create Desktop Entry ...".

If you want to create it for all users, just check the checkbox and click to "OK" button.  To create Unity launcher just drag and drop the icon into launcher bar.

Thursday, November 15, 2012

Disabling translator for Zend_Form_Element


If you use Zend_Form and also Zend_Translate, core Zend functionality tries to translate options of Zend_Form_Element_Select or any other options of elemenet inherited from Zend_Form_Element_Multi. This is not needed in all cases. To disable translator on the element just call function setDisableTranslator like this:


$element = new Zend_Form_Element_Select('my_element');
$element
            ->setDisableTranslator(true)

Wednesday, November 7, 2012

Recursively walk through directory tree

If you need to get all files (or also folders) from some folder and it's subfolders recursively, use following simple construction:

    $folder = '/path/to/folder';

    $objects = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($folder),
        RecursiveIteratorIterator::SELF_FIRST);

    foreach ($objects as $object)
    {
        /**
         * $object is instance of SplFileInfo
         */

        if ($object->isFile())
        {
            echo $object->getExtension();
            echo $object->getRealPath();
        }
    }
Check also PHP manual
     http://php.net/manual/en/class.recursiveiteratoriterator.php
     http://php.net/manual/en/class.recursivedirectoryiterator.php
     http://php.net/manual/en/class.splfileinfo.php







Tuesday, November 6, 2012

How to install PhpStorm on Ubuntu 12.10


If you want to try or use great php IDE PhpStorm follow these steps:


  1. download PhpStorm from http://www.jetbrains.com/phpstorm/download/

  2. unpack downloaded file with following command tar xfz PhpStorm-*.tar.gz (or right click in nautilus and choose "Extract Here")

  3. open folder "PhpStorm/bin/", right click to "phpstorm.sh", choose "properties. In permissions tab mark checkbox "Allow executing file as program"

  4.  install Oracle JDK by following commands:

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer



  5.  double click on file  "phpstorm.sh", click to "run"



Tuesday, November 10, 2009

timestamp from javascript date

Hi everybody, here's simple extension for javascript Date object. It returns timestamp in seconds in local time. Locale is taken from users browser.

Date.prototype.getTimestamp = function () 
{
var date = this;
var timestamp = Math.round(date.getTime()/1000);
timestamp = timestamp - (date.getTimezoneOffset () * 60);

return timestamp;
}


usage is simple:

var new_Date = Date();
alert(date.getTimestamp());

Thursday, June 25, 2009

Foreach equivalent in javascript

foreach function in PHP is very nice and easy to use. I was searching for equivalent in javascritp and there are two possibilities.

1. without jquery:


var new_array = new Array();
new_array[0] = 'foo';
new_array[1] = 'bar';

for (var key in new_array)
{
alert(new_array[key]);
}


2. using jquery


var new_array = new Array();
new_array[0] = 'foo';
new_array[1] = 'bar';

$.each(new_array, function(key, value)
{
alert(key + '=>' + value);
});


if you now another option using some other framework, please add it to discussion, thanks

Tuesday, October 21, 2008

Debuging php using vertrigo server and xdebug in eclipse

How to debug php scripts? Answer is easy. Here are few steps, how I have set it.

platform : windows
used software:

Few easy steps, how to set it
  1. download,  install and run vertrigo server

  2. download eclipse PDT 

  3. download "php_xdebug-2.0.3-5.2.5.dll" to
    "
    C:\Program Files\VertrigoServ\Php\ext\php_xdebug-2.0.3-
    5.2.5.dll"

  4. do NOT enable xdebug via vertrigo>settings>extensions settings

  5. edit "php.ini" saved in "C:\Program Files\VertrigoServ\Php\"  (right click on vertrigo tray icon > config files > php.ini)

    add at the end these lines :

    [xdebug]
    zend_extension_ts ="C:\Program Files\VertrigoServ\Php\ext\php_xdebug-2.0.3-5.2.5.dll"
    xdebug.remote_autostart=on
    xdebug.remote_enable=on
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9000
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.idekey=ECLIPSE_XDEBUG

    you need to turn off Zend optimizer (coment following lines):

    [Zend]
    zend_optimizer.optimization_level=15
    zend_extension_ts="C:\Program Files\VertrigoServ\Zend\ZendExtensionManager.dll"
    zend_extension_manager.optimizer_ts="C:\Program Files\VertrigoServ\Zend\Optimizer-3.3.0"

    like this:

    [Zend]
    zend_optimizer.optimization_level=15
    ;zend_extension_ts="C:\Program Files\VertrigoServ\Zend\ZendExtensionManager.dll"
    ;zend_extension_manager.optimizer_ts="C:\Program Files\VertrigoServ\Zend\Optimizer-3.3.0"

  6. find line "memory_limit = 8M" in "php.ini"
    change it to "
    memory_limit = 12M"   

  7. restart vertrigo (right click on tray icon > server > restart)