Sunday 28 August 2011

Apache xampp virtual hosts configuration on mac

After installing xampp on mac you need to change permission for /xamppfiles/etc/httpd.conf file. There is simple program for that, called BatChmod.

Next you need to enable it for user thsty you want:

Find:
User nobody
Group nogroup

Change it to:
User YOURUSERNAME
Group admin



If you projects are in another location you will need to change DocumentRoot in httpd.conf to you path, and also need to change line
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
to you path, and "Deny from all" to "Allow from all" to this directory


After that uncomment
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

Here is where you put your virtual hosts. 

It should look like :

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
  ServerName yourdomain.dev
  DocumentRoot "/Users/
username/projects/your_project"
  DirectoryIndex index.php
  <Directory "/Users/
username/projects/your_project">
    Options +Indexes FollowSymLinks +ExecCGI
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
  ServerName localhost
  DocumentRoot "/Users/username/projects/"
  DirectoryIndex index.php
  <Directory "/Users/
username/projects/">
    Options +Indexes FollowSymLinks +ExecCGI
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
 
Last thing, add yourdomain to hosts

Open the Terminal and type:
sudo pico /etc/hosts

Now enter your admin password. You'll get a little text editor in the console. Go to the last line and add this line:
127.0.0.1 yourdomain.dev with the correct name for every virtual host you would like to set up. When you're done, type control-o, then enter and then control-x in order to save and close.

Friday 5 August 2011

simple ajax call

This is part for the view script:

function addAdditional(lnk) {
        jQuery.ajax({
                        type: "POST",
                        url: "<?php echo $this->url(array('controller' => 'content', 'action' => 'vote'), 'default', true); ?>",
                        data: jQuery('#star-form').serialize()+'&content_id=' + <?php echo $this->content_id ?>,
                        success: function(res)
                        {
                            r = jQuery.parseJSON(res);
                            if(r.status == 'success')
                            {
                                if(r.saved == 'success') {
                                    $("#vote-button").next().html('Uspesno ste glasali!');
                                } else {
                                    $("#vote-button").next().html('Niste glasali. Pokusajte ponovo!');
                                }

                            }
                            else
                            {
                                $("#vote-button").next().html('Niste glasali. Pokusajte ponovo!');
                            }
                        }
                    });
        return false;
    }

Here is the controller action

public function voteAction() {
        $result = array(
            "status" => "",
            "saved" => "",
        );

        if ($ok) {
            //do code
            $result = array(
                "status" => "success",
                "saved" => "success",
            );
        } else {
            $result = array(
                "status" => "success",
                "saved" => "error",
            );
        }

        die(json_encode($result));
    }

Thursday 4 August 2011

Using selenium server with netbeans

Fisst of all you need to have php unit installed. PHPUnit should be installed using the PEAR INSTALLER. I didnt have go-pear.bat in my wamp 2.1, so i copied it from xamp server and ran "php -d phar.require_hash=0 PEAR/go-pear.phar" command, then you nedeed to upgrade pear using "pear install PEAR-1.9.3" command. Now install php Unit http://www.phpunit.de/manual/current/en/installation.html.

Zend send variable to a form

We create variable that we need in controller:

$this->view->random = date('YmdHis').rand(10000, 9999).rand(10000, 9999);


Then we pass it to a form call in controller:

$this->view->form = new Application_Form_ContentGame(array('random'=>$this->view->random));


And in a form, we get it with:

$random = $this->getAttrib('random');