Monday, December 14, 2015

Nothing to update - your database is already in sync with the current entity metadata.

Have add many to one and on to many table relation ship many times and tried:
php app/console doctrine:schema:update many times but still can't see any database changes. finally found should remove the yml files from Resources/config/doctrine folder. And then the problem solved.

Tuesday, November 24, 2015

Prototype javascript 原型的方法

isPrototypeOf(new instance); //判断原型的方法
Object.getPrototypeOf(); //根据实例对象获得原型对象
hasOwnProperty(object, 属性);
in // 操作符 判断属性是否在于实例对象和原型对象中
Object.Keys(); //拿到当前对象里的所有keys 返回一个数组
constructor属性: 该属性是不能被枚举(eable = false)
Object.getOwnPropertyNames 枚举对象所有的属性,不管该内部属性能否被枚举


Sunday, November 22, 2015

javascript ()

if wanna run a function immediately we can use () to run it. the () is run in Javascript.

function test(){
  (function (){
    //run me first,
  })();
// this one used 2 () to run the function first.

   for()....
}

Saturday, November 21, 2015

js this

this  总是指向调用者,也就是说,谁调用了我,我就指向谁。

symfony1 ajax respones and add component on action

json response:
$this->getResponse()->setHttpHeader('Content-type', 'application/json');
return $this->renderText(json_encode($todo));

function addNewTodo(checklist_id)
{
  var body = jQuery('#todo_body_' + checklist_id).val();
    jQuery.ajax({
      url: "url_for('checklist/addtodo'); ?>",
      type: 'POST',
      data: {'id': checklist_id, 'body': body},
      dataType: 'json',
      beforeSend: function () {
        jQuery('#indicator').show();
      },
      success: function (data) {
        jQuery('#indicator').hide();
      }
    });
  return false;
}

component in action:
return $this->renderComponent ('checklist', 'checklist_tr', array(    'todo_id'  =>  $todo->getId(),    'todo_status'  =>  false,    'todo_body'  =>  $todo->getBody(),    'project_id' => $project_id));
function addNewTodo(checklist_id)
{
  var body = jQuery('#todo_body_' + checklist_id).val();
    jQuery.ajax({
      url: "url_for('checklist/addtodo'); ?>",
      type: 'POST',
      data: {'id': checklist_id, 'body': body},
      dataType: 'text',
      beforeSend: function () {
        jQuery('#indicator').show();
      },
      success: function (data) {
        jQuery('#indicator').hide();
      }
    });
  return false;
}

Saturday, August 15, 2015

Warning: date_default_timezone_get(): on Mac Mamp Pro

http://cullenwebservices.com/symfony-getting-started-tutorial-architecture/

[Symfony\Component\Debug\Exception\ContextErrorException]                                                        Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.                                                  

                                                                                 

Copy this file to php.ini like this:
1sudo cp /private/etc/php.ini.default /private/etc/php.ini
then change this line:
1date.timezone = "Pacific/Auckland"

Monday, April 20, 2015

Symfony2 install intl extension on Mac Mamp solution

Notes:

Why MAMP ? Because it’s the easiest way to work locally with Symfony 2 at the moment. It comes with an updated APC extension and requires only the INTL extension which we will compile in this how-to. Please follow the requirements and instructions step by step.

Requirements:

  1. Download and install Xcode from the App Store. (current release 4.3.3).
  2. Download and install the Command Line Tools for Xcode from Preferences > Downloads in Xcode.
  3. Install Macports. Follow the instructions on Macports

Step 1: Get the Web-Server

Go to Mamp and download the current version of MAMP. After installing delete the MAMP PRO directory (you won't need it) and run MAMP.
In the window click on Preferences… then on Ports. There change the current server ports to their default ports. MAMP will automatically restart both servers so we can finally start setting up Symfony 2.

Step 2: Get the framework

Go to Symfony and download the current release (2.1.3). Unpack it and move the Symfony folder to your local htdocs which is located in: /Applications/MAMP/htdocs
Now we will configurate our web-server to make Symfony 2 work. Open the following URI in your Browser:http://localhost/Symfony/web/config.php
You will most likely get something like this:
Symfony Recommendations

Step 3: Get the extensions

  1. Open your Terminal by either pressing both [⌘ + space] and writing Terminal or from the filesystem/Applications/Utilities/Terminal.app and type:
    1. sudo port install php5-intl
    or if you have PHP 5.4.X (thanks to Andrew Knight):
    1. sudo port install php54-intl
    In case you get the warning that no indexes could be found run the following line and then try the upper command again:
    1. sudo port -d sync
  2. Get yourself some tea and try to gather some reputation on Stackoverflow. This is going to take some time.
  3. Type the following into your Terminal and press [tab] for auto-completion - then [return]:
    1. cd /opt/local/lib/php/extensions/no-debug-non-zts-
    (the php extentsions folder maybe in different location my one is /opt/local/lib/php54/extensions/no-debug-non-zts-20100525/intl.so) Now your are located in the directory where our extension has been compiled (via Terminal). Type:
    1. open .
    Now your Finder is going to popup just where our intl.so extension is located. Copy that file and put it into your MAMP php-extensions directory. For PHP 5.3 it would be:
    /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-yyyymmdd/

Step 4: Do the configuration

  1. Navigate to the following directory (via Finder and assuming with PHP 5.3) to change a few settings:/Applications/MAMP/conf/php5.3/
  2. Now drag the file php.ini onto your desktop (where you can edit it) an open it with your favorite text editor. I did the changes with the default editor TextEdit.
    [⌘ + F] and search for short_open_tag and change it to off.
    [⌘ + F] and search for magic_quotes_ and add the following line after: magic_quotes_sybase = off
    magic_quotes_gpc = off
    [⌘ + F] and search for 'extension=apc.so' and add the following line to the extensions section:
    extension=intl.so
  3. Now save and move the file back to it’s original directory. Now restart your web-server (via Mamp).

Sunday, March 22, 2015

use angular js in Symfony2

just need add the code below and then will use __  __to instead of {{}}

angular.module('demo', [])
.config(['$interpolateProvider', function($interpolateProvider) {
$interpolateProvider.startSymbol('__');
$interpolateProvider.endSymbol('__');
}]);


add js, css, images on web/bundles/bundleName folder

php app/console assets:install --symlink

Wednesday, January 7, 2015

Mac install phpunit in MAMP or Symfony2

1. in symfony find composer.json and add phpunit/phpunit which can be found in https://packagist.org/packages/phpunit/phpunit

{
    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    }
}

2. run command composer update
3. change the path by command line: PATH="~/.composer/vendor/bin:/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.4.19/bin:$PATH"

now we can type "phpunit --version" to test.


install it 
$ wget https://phar.phpunit.de/phpunit.phar

$ chmod +x phpunit.phar

$ mv phpunit.phar /usr/local/bin/phpunit