Monday, January 18, 2016

How to install Symfony

1) run following command
php -r "file_put_contents('symfony', file_get_contents('https://symfony.com/installer'));"

2) run following command
symfony new my_project 2.8

3) see picture below














4) Run on web













In php ini open this extension
extension=php_intl.dll

Note: if you not installed Php accelerator, please install by following steps

  1. to show you PHP configuration via the PHP function phpinfo() ;
  2. to get 2 precious informations :


x86 or x64, and TS (Thread Safe) or NTS (Non Thread Safe) ;
3.to download the corresponding DLL there (including your PHP version) http://pecl.php.net/package/APCu/4.0.6/windows


4. to copy/paste the DLL file within your extensions directory,
5. to edit your php.ini file (i.e. within C:xampp/php directory) ;
and add this line inside Dynamic Extensions part :
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

[...]

extension=php_apcu.dll

Don't forget to restart server.


Read More »

Tuesday, January 5, 2016

Cakephp validate

we can do validation with Model in cakephp by  array variable  i.e  $validate.

here you can see working validation example which you have to write in model

public $validate = array(
            'username' => array(
                'notBlank' => array(
                    'rule' => array('notBlank'),
                    'message' => "Please enter username",
                ),
            ),
            'password' => array(
                'notBlank' => array(
                    'rule' => array('notBlank'),
                    'on' => 'create',
                    'message' => "Please enter password",
                ),
            ),
            'email' => array(
                'notBlank' => array(
                    'rule' => array('notBlank'),
                    'message' => "Please enter email",
                ),
                'email' => array(
                    'rule' => array('email'),
                    'message' => "Please enter valid email",
                ),
               'isUnique' => array(
                    'rule' => 'isUnique',
                    'message' => 'Email already registered'
               ),
            )
        );

you can also validate in controller  see below code snippet

if ($this->User->validates()) {
     // do whatever you want after all fields beings validated
}else{
     $this->set('data', $this->request->data);
     $this->validateErrors($this->Sendmail);
     $this->render();
}


suppose you have two submit  button in one form  like Btn1  and Btn2
On click of Btn1 you want to validate some fields and on click of Btn2 you want to validate all fields
Then you can have more than one validates array and select which one you want to use before you save

see below code snippet for model

public $validate = array(
   // default validation rules
);

public $validateforallfields = array(
   // validation rules including password validation
);


Now, in your controller action you can select to validate with the all fields with:

$this->User->validate = $this->User->validateforallfields;


Thanks to watch :)


Read More »