Saturday, March 14, 2015

Symfony 2 - Duplicate an entity

public function duplicateAction(Request $request, $id){    $em = $this->getDoctrine()->getManager();    $entity = $em->getRepository('ABundle:B')->find($id);    if (!$entity) {        throw $this->createNotFoundException('Unable to find B entity.');    }    $new_entity = clone $entity;    $em = $this->getDoctrine()->getManager();    $em->persist($new_entity);    $em->flush();    return $this->indexAction();}

Monday, February 23, 2015

How to generate "bootstrap.php.cache"

If you ever need to generate the bootstrap.php.cache file for a Symfony2 Version higher or equal to 2.1, this will do the Job: 


php /vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php


Hope you save some time with this ;)

Wednesday, February 18, 2015

Friday, February 06, 2015

Install google-closure-linter on Ubuntu or closure-linter package in Ubuntu

sudo apt-get install build-essential
sudo apt-get install python-cheetah
wget http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz
or
sudo apt-get install closure-linter

Tuesday, January 27, 2015

Switch to UTF-8 charset in Mysql on Ubuntu

When installing Mysql on Ubuntu the default character set is probably latin-1. Since Ubuntu uses UTF-8 for most other things this may be little strange. But it is easy to change.


The Mysql configuration file /etc/mysql/my.cnf has a magic line:

!includedir /etc/mysql/conf.d/

This will make it include settings on the subdirectory conf.d. It's not recommended to change themy.cnf file directly since it will cause problems when upgrading Ubuntu/Mysql to a new version.

Create a new file: /etc/mysql/conf.d/utf8_charset.cnf with the following contents:

[mysqld]
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

[client]
default-character-set=utf8

Restart mysql and you will have UTF-8 as character set:


$ mysql -u root -p -e 'show variables like "%character%";show variables like "%collation%"';



+--------------------------+----------------------------+

| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database   | utf8_unicode_ci |
| collation_server     | utf8_unicode_ci |
+----------------------+-----------------+

if you want to change the DB
alter database <database> character set utf8 collate utf8_unicode_ci;

Monday, January 26, 2015

https://octobercms.com/

October is a free, open-source, self-hosted CMS platform based on the Laravel PHP Framework. It is a productivity tool for building modern websites based on flexible patterns and principals rooted in simplicity.

https://octobercms.com/

Sylius

Built on the shoulders of open source giants
Symfony2 as the enterprise-class PHP framework
Doctrine as ORM and database abstraction
Behat and phpspec for BDD

http://sylius.org/

systemd-timesyncd

sudo apt update && sudo apt install systemd-timesyncd && sudo systemctl enable --now systemd-timesyncd