Category Archives: Senza categoria

Logrotate with dateext is better for rdiff-backup

rdiff-backup is a very neat tool to perform incremental backups on *nix machines. You can learn more about it on GitHub.

logrotate is a standard *nix utility to… well, rotate logs 🙂

If you do backups of your logs with rdiff-backup, the default configuration is going to take a lot of useless space, so let’s see a better way to use them. In the post we will assume a daily rotation.

Continue reading Logrotate with dateext is better for rdiff-backup

Creating a theme system with Twig and Symfony

What’s Twig

If you use Symfony you also probably use Twig (http://twig.sensiolabs.org/). It is a very flexible layout system and it makes it really easy to:

  • extend a base layout
  • include external sublayouts

Even though Twig requires you to learn a slightly different syntax, I feel it’s well worth it and I am completely happy with it. Let’s take a look on how to handle “themes” with Twig.

Continue reading Creating a theme system with Twig and Symfony

Connect to MSSQL from Linux Ubuntu with Symfony and Doctrine

tl;dr

  1. Install the php5-sybase package
    This will install on Ubuntu the drivers required to connect to a Microsoft SQL Server.
  2. Test connection from PHP
    We want to make sure PHP is working before moving on to Doctrine. See below for a sample test PHP script.
  3. Install the leaseweb/doctrine-pdo-dblib bundle
    Doctrine out of the box does not support connecting to a MSSQL server from Linux. This bundle “forces” Doctrine to do it.

Sample test PHP script

Here’s a short PHP script that you can run from the command line to test that the connection to MSSQL is working fine.

$dbh = new PDO ("dblib:host=192.168.0.1;dbname=mydatabase","user","password");
$stmt = $dbh->prepare("SELECT * FROM products");
$stmt->execute();
while ($row = $stmt->fetch()) {
  print_r($row);
}

 

Install and enable WKHTMLTOPDF 0.12 on Ubuntu Server 14.04 or 16.04

WKHTMLTOPDF is a very handy binary tool to create PDF from HTML. I used it already in many projects and I am very happy with the results.

But the initial setup could be a little tricky if you don’t know your way around a Linux server. The following procedure works for me with WKHTMLTOPDF v.0.12.3 on Ubuntu Server 14.04 or 16.04:

Continue reading Install and enable WKHTMLTOPDF 0.12 on Ubuntu Server 14.04 or 16.04