Monday, December 15, 2014

windows wamp or mamp install pecl_http

add these 3 dll files under:
php_raphf.dll
php_propro.dll
php_http.dll

download from under url

http://windows.php.net/downloads/pecl/snaps/propro/1.0.0/
http://windows.php.net/downloads/pecl/releases/http/2.1.4/
http://windows.php.net/downloads/pecl/releases/raphf/1.0.4/

add 3 lines on php.ini

extension=php_raphf.dll
extension=php_propro.dll
extension=php_http.dll

restart apache 

Sunday, December 14, 2014

Symfony controller

public function indexAction() { return $this->redirect($this->generateUrl('homepage')); }

public function indexAction() { return $this->redirect($this->generateUrl('homepage'), 301); }

use Symfony\Component\HttpFoundation\RedirectResponse; return new RedirectResponse($this->generateUrl('homepage'));

404error page
 public function indexAction() { // retrieve the object from database $product = ...; if (!$product) { throw $this->createNotFoundException('The product does not exist'); } return $this->render(...); }

Session.
use Symfony\Component\HttpFoundation\Request; public function indexAction(Request $request) { $session = $request->getSession(); // store an attribute for reuse during a later user request $session->set('foo', 'bar'); // get the attribute set by another controller in another request $foobar = $session->get('foobar'); // use a default value if the attribute doesn't exist $filters = $session->get('filters', array()); }

Flash message
use Symfony\Component\HttpFoundation\Request; public function updateAction(Request $request) { $form = $this->createForm(...); $form->handleRequest($request); if ($form->isValid()) { // do some sort of processing $request->getSession()->getFlashBag()->add( 'notice', 'Your changes were saved!' ); return $this->redirect($this->generateUrl(...)); } return $this->render(...); }

Flash message in layout
{% for flashMessage in app.session.flashbag.get('notice') %}
    
class="flash-notice"> {{ flashMessage }}
{% endfor %}

Saturday, December 6, 2014

how to install openssl on Mac

sudo port install php5-openssl

Install Intl extension on MAMP Pro for Mac


  1. download icu http://site.icu-project.org/download
  2. tar xzvf icu4c-54m1-src.tgz
  3. cd icu/source
  4. ./runConfigureICU MacOSX
  5. ./configure
  6. make
  7. sudo make install
waiting for install icu completed.


8.  export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH
9.  sudo pecl install intl
10. add "extension=intl.so" to php.ini

restart Apache.

Thursday, September 18, 2014

Symfony1: use helper in action class

$this->getContext()->getConfiguration()->loadHelpers('Partial');


$this->generateUrl("userSignup");
The method is defined in sfComponent.class.php. This is the recommended way, not the hacky workaround of loading the view helpers and using them.

Thursday, August 21, 2014

zend controller front

$params = Zend_Controller_Front::getInstance()->getRequest()->getParam('contactID');

$this->_view->

Zend_Registry::get('client');

in the Zend Controller
$params = $this->getRequest()->getParam('contactID');

_______________________________________________________________
disable Layout

public function listaAction()
    {    
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
    }
_______________________________________________________________
Use helper in view
in Bootstrap.php
add $this->addHelperPath('App/View/Helper', 'App_View_Helper);

Friday, June 27, 2014

sticky footer

Html5

* {
 margin: 0;
}
html, body {
 height: 100%;
}
.wrapper {
 min-height: 100%;
 height: auto !important;
 height: 100%;
 margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */
}
footer, .push {
 height: 155px; /* '.push' must be the same height as 'footer' */
}

/*

Html

* {
 margin: 0;
}
html, body {
 height: 100%;
}
.wrapper {
 min-height: 100%;
 height: auto !important;
 height: 100%;
 margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
 height: 155px; /* .push must be the same height as .footer */
}

/*

Sticky Footer by Ryan Fait
http://ryanfait.com/

*/


  1.     
  2.         
  3.     
  •     
  •         
  •             Your website content here.
  •             
  •         </div>
  •         
  •             Copyright (c) 2008
  •         </div>
  •     


  • Monday, June 23, 2014

    Silverstripe how to install modules

    1. download module
    2. copy to the root folder
    3. backup database.
    4. on front page, run http://localhost/yoursite/dev/build/?flush=1
    5. done.

    Monday, June 16, 2014

    solved ZF ERROR -- In order to run the zf command

    ************** ZF ERROR ***************** 
    In order to run the zf command, you need to ensure that Zend Framework is inside your include_path. There are a variety of ways that you can ensure that this zf command line tool knows where the Zend Framework library is on your system, but not all of them can be described here.
    The easiest way to get the zf command running is to give it the include path via an environment variable ZEND_TOOL_INCLUDE_PATH or ZEND_TOOL_INCLUDE_PATH_PREPEND with the proper include path to use, then run the command "zf --setup". This command is designed to create a storage location for your user, as well as create the zf.ini file that the zf command will consult in order to run properly on your system.
    Example you would run:
    $ ZEND_TOOL_INCLUDE_PATH=/path/to/library zf --setup
    Your are encourged to read more in the link that follows. Zend_Tool & CLI Setup Information (available via the command line "zf --info") * Home directory found in environment variable HOMEPATH with value \Users\TOS H * Storage directory assumed in home directory at location \Users\TOSH/.zf/ * Storage directory does not exist at \Users\TOSH/.zf/ * Config file assumed in home directory at location \Users\TOSH/.zf.ini * Config file does not exist at \Users\TOSH/.zf.iniv, you need to ensure that Zend Framework is inside your include_path. There are a variety of ways that you can ensure that this zf command line tool knows where the Zend Framework library is on your system, but not all of them can be described here.
    The easiest way to get the zf command running is to give it the include path via an environment variable ZEND_TOOL_INCLUDE_PATH or ZEND_TOOL_INCLUDE_PATH_PREPEND with the proper include path to use, then run the command "zf --setup". This command is designed to create a storage location for your user, as well as create the zf.ini file that the zf command will consult in order to run properly on your system.
    Example you would run:
    $ ZEND_TOOL_INCLUDE_PATH=/path/to/library zf --setup
    Your are encourged to read more in the link that follows. Zend_Tool & CLI Setup Information (available via the command line "zf --info") * Home directory found in environment variable HOMEPATH with value \Users\TOS H * Storage directory assumed in home directory at location \Users\TOSH/.zf/ * Storage directory does not exist at \Users\TOSH/.zf/ * Config file assumed in home directory at location \Users\TOSH/.zf.ini * Config file does not exist at \Users\TOSH/.zf.ini

    Solution

    php.ini for CLI is different from the one you open using wamp which is for webserver (apache)
    C:\wamp\bin\apache\Apache2.2.21\bin\php.ini
    you should add include_path in following ini aswell
    C:\wamp\bin\php\php5.3.10\php.ini
    Note depending upon your versions of php , apache path could be little different.

    Wednesday, June 11, 2014

    How to use zf on mac

    If you can't copy the zf library in some "global" include path, e.g. /usr/share/php/, you can still copy it where your project is and start the zf tool from there. A folder structure like:
    /var/www/zf_tool
                    `/bin/
                          `zf.sh
                          `zf.php
                    `/library
                          `/Zend
    Copy the Zend folder under library, and the zf.sh and zf.php scripts under bin and set them to be executable chmod a+x zf.sh zf.php if they are not already. Next, if you run /var/www/project/bin/zf.sh it'll look for zf files in the include_path, but if it's not there, it'll go up one folder and go into the library folder. Only if the zf library is not to be found there, it'll die with an error. In the end, creating a new zf project is simple as:
    $ pwd
    /var/www/zf_tool/bin
    $ ./zf.sh create project /var/www/test_project

    Thursday, April 10, 2014

    install zend2 on mac mamp

    install composer.phar first

    curl -s http://getcomposer.org/installer | php


    get in to the project directory


    1. git clone git://github.com/zendframework/ZendSkeletonApplication.git

    copy all files to the project directory 
    2. php composer.phar self-update
    3. php composer.phar install

    Monday, March 24, 2014

    Wednesday, January 15, 2014

    install mcrypt on Mac


    #!/usr/bin/sh

    # Scipt for installing mcrypt.so extension for PHP 5.3.13 (default PHP for OS X 10.8 Mountain Lion)

    mkdir /tmp/mcrypt
    cd /tmp/mcrypt

    curl --location --progress-bar http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download | tar -zx
    curl --location --progress-bar http://nz1.php.net/get/php-5.4.24.tar.gz/from/this/mirror | tar -zx

    cd /tmp/mcrypt/libmcrypt-2.5.8
    MACOSX_DEPLOYMENT_TARGET=10.8 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64'  ./configure --disable-dependency-tracking
    make -j6  
    sudo make install

    cd /tmp/mcrypt/php-5.3.13/ext/mcrypt/
    phpize  
    MACOSX_DEPLOYMENT_TARGET=10.8 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64'  ./configure --with-php-config=/usr/bin/php-config
    make -j6
    sudo make install

    cd ~ && rm -rf /tmp/mcrypt

    echo "Don't forget to add 'extension=mcrypt.so' to /etc/php.ini"

    from https://gist.github.com/n3b/4060272