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.