Install thelia

 

  1. Get code
    git clone https://github.com/thelia/thelia.git
  2. Change version of propel
    open composer.json
    update version of propel: “propel/propel”: “2.0.0-alpha2”,
  3. Create a virtual host:
    <VirtualHost *:80>
    ServerName thelia.dev
    ServerAlias http://www.thelia.dev
    DocumentRoot /path/to/thelia/web
    <Directory /path/to/thelia/web>
    # enable the .htaccess rewrites
    AllowOverride All
    Require all granted
    </Directory>
    ErrorLog /path/to/thelia/error.log
    CustomLog /path/to/thelia/access.log combined
    </VirtualHost>
  4. Enable vhost alias
    sudo a2enmod rewrite vhost_alias
  5. Install dependencies
    cd /path/to/thelia/
    composer self-update
    composer update
  6. Fix permissions
    chmod a+w -R /path/to/thelia/cache/
    chmod a+w -R /path/to/thelia/log/
    chmod a+w -R /path/to/thelia/local/config
    chmod a+w -R /path/to/thelia/local/session
    chmod a+w -R /path/to/thelia/local/media
  7. Edit php.ini
    sudo vim /etc/php5/apache2/php.ini
    /post_max_size
    post_max_size = 100M
    extension=mcrypt.so
  8. Chown web/
    sudo chown user:www-data -R web/
    sudo chmod a+w -R web/
  9. Create datable and import structure
    create thelia database
    import install/thelia.sql for database structure
    import install/insert.sql for configurations
  10. rm local/config/database.yml
  11. go to thelia.dev and follow the instructions
  12. Import realistic productions
    php install/import.php
Advertisements

Ssl trong Symfony 2

1. Start server trong xampp

start xampp
sudo /opt/lampp/lampp startssl

stop xampp
sudo /opt/lampp/lampp stopssl

2. Trong Route symfony 2

….
prefix:   /admin
requirements:
_scheme:  https

3. Trong Virtual host

<VirtualHost 127.0.0.1:443>
ServerAdmin admin@website.com
DocumentRoot “/home/me/website/web”
ServerName website.com
ErrorLog “/home/me/website/error_log”
CustomLog “/home/me/website/access_log” common
<Directory “/home/me/website/web”>
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile “/opt/lampp/etc/ssl.crt/server.crt”
SSLCertificateKeyFile “/opt/lampp/etc/ssl.key/server.key”
</VirtualHost>

Annotation trong Doctrine 2

/**
* @Assert\NotBlank()
*/

/**
* @Assert\Choice(
*     choices = { “male”, “female” },
*     message = “Choose a valid gender.”
* )
*/

/**
* @Assert\Choice({“male”, “female”})
*/

/**
* @Assert\NotBlank()
* @Assert\Length(min = “3”)
*/

/**
* @Assert\True(message = “The password cannot match your first name”)
*/
public function isPasswordLegal()
{
// return true or false
}

/**
* @Assert\Email(groups={“registration”})
*/
private $email;

/**
* @Assert\NotBlank(groups={“registration”})
* @Assert\Length(min=7, groups={“registration”})
*/
private $password;

/**
* @Assert\Length(min = “2”)
*/
private $city;

Date time trong PHP

1. Một số expression:

$date = new DateTime('now');

This week: $date = new DateTime('last Monday');
$date = new DateTime('next Sunday');

This time tomorrow: $date = new DateTime('now +1 day');

(This time) first day of This month: $date = new DateTime('first day of this month');
(This time) last day of This month: $date = new DateTime('last day of this month');

In this month:
$firstDayThisMonth = new DateTime('first day of this month');
$firstDayThisMonth->setTime(0, 0, 0);
$firstDayNextMonth = new DateTime('first day of next month');
$firstDayNextMonth->setTime(0, 0, 0);

$firstDayThisMonth->format('Y-m-d H:i:s');
$firstDayNextMonth->format('Y-m-d H:i:s');

First day of this month, no time: date('Y-m-01', time());
Last day of this month, no time: date('Y-m-t', time());

$first_minute = mktime(0, 0, 0, date("n"), 1);
$last_minute = mktime(23, 59, 0, date("n"), date("t"));

2. Modifier
$time = strtotime(‘modify’, $timestamp);
e.g. $time = strtotime(‘+2 days’, 12345567);
$time = strtotime("-1 week");

3. Time Zone
php.ini: timezone=”Asia/SaiGon”
or: $date = new \DateTime(“”, new \DateTimeZone(“Asia/Saigon”)) ;

4. Format
$date_time = $date->format('Y-m-d H:i:sP');

5. Notes
// Never use math like 60*60*24*7 to add/subtract days (because of daylight time saving)