tag:blog.jaumesola.com,2013:/posts Jaume Solà 2017-03-08T10:35:36Z Jaume Sola tag:blog.jaumesola.com,2013:Post/948712 2015-12-13T18:01:34Z 2015-12-13T18:42:59Z Symfony 3 on MAMP with Mercurial VCS and Eclipse IDE - part 2

Part 1 http://blog.jaumesola.com/symfony-3-on-mamp-with-mercurial-vcs-and-eclipse-ide-part-1

As it already "does something" we will continue with the demo app.


  • Next step: mercurial repository. Initialize:
cd /Users/MyUser/Workspace/symfony_demo_01
hg init
  • set at least user name parameter for Mercurial
vi .hg/hgrc

username = myself
  • Define files to be ignored -- Mercurial similar format than git, just remove trailing slash "/" on every line
cp .gitignore .hgignore
vi .hgignore
  • initialize repository
hg addremove
hg commit

Eclipse & debugger

Create Project

  • File - Import... - Mercurial - Projects from local Mercurial repository

You may now commit the newly created .project file


MAMP already comes with xdebug but it has to be enabled:
  • activate it in the currently used MAMP php-ini file: uncomment the loading of the extension and enable remote debugging
vi /Applications/MAMP/bin/php/php5.6.7/conf/php.ini

xdebug.remote_enable = On
  • Now you can create a debug configuration in Eclipse. In my case it worked with the following settings
    • server - Base URL: http://symfony_demo_01.loc:8888
    • server - Path Mapping: / -> /Users/MyUser/Workspace/symfony_demo_01
    • file: app.php

YAML files

The default installation uses YAML files for configuration options. There's an Eclipse YAML editor called Yedit, but I couldn't make it work so I just associated the .yml extension to the default text editor.

Jaume Sola
tag:blog.jaumesola.com,2013:Post/948434 2015-12-13T17:05:12Z 2015-12-13T17:05:13Z Symfony 3 on MAMP with Mercurial VCS and Eclipse IDE - part 1

I use MAMP+Mercurial+Eclipse as PHP development environment on Mac OS X. These are instructions for this environment adapted from https://symfony.com/doc/current/book/installation.html

  • As the Symfony 3 installer uses the default system php command, we will first make sure that it takes the one from MAMP we want, in this case PHP version 5.6.7. For this we will create an alias which for convenience you’ll probably want to add to .bashrc: 
alias php=/Applications/MAMP/bin/php/php5.6.7/bin/php

  • Check the PHP version you are using with: 
php --version
  • you may also check the php.ini file being used in case some change is required
php --ini

  • As admin user:
sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

  • As your regular user:
symfony new symfony_test_01
  • app is installed on user’s home page. You may want to move it to some other folder

mv /Users/MyUser/symfony_test_01 /Users/MyUser/Workspace/

  • run it

cd /Users/MyUser/Workspace/symfony_test_01
php bin/console server:run

you should get this:

 [OK] Server running on                                                                                                                                                                                             

// Quit the server with CONTROL-C.
  • Point the browser to the URL shown by the last command and verify it works

With this we've verified it works with the PHP's built-in server.
For a number of reasons I prefer to setup an Apache virtual host instead of using it, even if this requires more work.
  • For that we create a virtual host configuration file for Apache. This file may contain something like this:
########## symfony_test_01.loc

<VirtualHost *:8888>
DocumentRoot "/Users/MyUser/Workspace/symfony_test_01/web"
ServerName symfony_test_01.loc
ErrorLog "/Users/MyUser/Workspace/symfony_test_01/var/logs/apache-error_log"
CustomLog "/Users/MyUser/Workspace/symfony_test_01/var/logs/apache-access_log" common
<Directory "/Users/MyUser/Workspace/symfony_test_01/web">
DirectoryIndex app.php
  • We save this file as apache_vhost.conf
  • Now we make a Apache-MAMP to load this file. For that you can do something like:
echo "Include /Users/MyUser/Workspace/symfony_test_01/apache_vhost.conf" >> /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf 
Note that I included a fake domain name "symfony_test_01.loc". This is to allow several projects to run on the same server (localhost)
  • So for this domain name to work we'll add it to /etc/hosts. As admin:
sudo sh -c "echo ' symfony_test_01.loc' >> /etc/hosts"
  • Start MAMP
  • Now we verify it works by pointing the browser to the URL
  • Then check if there's some configuration issue worth fixing:
  • Managing components in Symfony is easier with the composer package manager, so here's how to install it if you don't have it
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer about
  • Update packages that may have newer versions
composer update
  • Yet another check
php bin/console security:check
Now we will try with a demo app that implements a list or articles (= a barebones blog without comments)
cd /Users/MyUser/Workspace
symfony demo
mv symfony_demo symfony_demo_01
  • and repeat some of the previous steps top make it work

Jaume Sola
tag:blog.jaumesola.com,2013:Post/604720 2013-09-27T12:09:31Z 2013-10-08T17:30:40Z PHP + Ruby Development Environment on Mac OS X Note: This article is about PHP only, in a forthcoming one I will include Ruby.

There are many possible tools, this is the stack I use:
  • Mac OS X 10.6 Snow Leopard/10.7 Mountain Lion
  • MAMP 2.2
  • Ruby - rvm
  • Aptana Studio 3.4.2
  • Mercurial
  • [Dropbox for manual sync between two computers (e.g. desktop & laptop)]
And these are my particular reasons for it:
  • I'm already familiar with Eclipse, and Aptana comes with built-in support for Ruby, Python, PHP and JavaScript.
  • I develop/maintain a number of applications in Ruby and PHP, and I prefer to use the same tool for both languages.


Create a PHP project

  • Create a project on Aptana with your PHP application. 
    • I typically use File->Import-> Existing Folder as New Project
    • Let's assume you use the folder /Users/myuser/Workspace/PHPProject
    • If you haven't created a Mercurial repository, you can do it now from the terminal:
cd /Users/myuser/Workspace/PHPProject/
hg init
Open the project on Aptana (right click) and you should see:

  • For this example let's create a public/ folder and a index.php file in it with the following content:
    header("Content-Type: text/plain");
    echo "Hi, I'm your newborn PHP project";
    • Add a virtual host in apache. Edit /Applications/MAMP/conf/apache/httpd.conf & uncomment the line:   
    # Virtual host
    Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
    •  Edit /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
      • We will use the first sample entry, dummy-host.example.com
      • Change the DocumentRoot directive to point to the public folder of this project.
      • Also change port 80 to 8888
    NameVirtualHost *:8888
    <VirtualHost *:8888>
        ServerAdmin webmaster@dummy-host.example.com
        DocumentRoot "/Users/myuser/Workspace/PHPProject/"
        ServerName dummy-host.example.com
        ServerAlias www.dummy-host.example.com
        ErrorLog "logs/dummy-host.example.com-error_log"
        CustomLog "logs/dummy-host.example.com-access_log" common
    </VirtualHost>       dummy-host.example.com localhost
      • Verify it works
    $ ping dummy-host.example.com
    PING dummy-host.example.com ( 56 data bytes
    64 bytes from icmp_seq=0 ttl=64 time=0.063 ms
    64 bytes from icmp_seq=1 ttl=64 time=0.022 ms
    64 bytes from icmp_seq=2 ttl=64 time=0.112 ms
    Hi, I'm your newborn PHP project
      If you're not familiar with Mercurial, this is my minimal cheatsheat.

      This is our first version of this application. We commit it to the Mercurial repository: Right click, Team, Commit...


        • Uncomment at the end of the php.ini (see its location in the phpInfo page), plus add the line below to enable "remote" (Apache) debugging
        xdebug.remote_enable = On
        • Restart MAMP, refresh phpInfo page and verify that now an xdebug section appears.
        • Aptana:

          • Aptana:
            • Window -> Open Perspective -> Debug
            • Bug Icon, Debug preferences, New_configuration
            • Set PHP server:

            •  Set the starting PHP script index.php, unset "Auto Generate" and empty the field at right

          We are ready to debug our "application". Press the "Debug" button and a new browser window should popup showing our magnificent message:

          Now we can set a breakpoint, and debug again; execution should stop at the breakpoint (browser window waiting) and should finish by pressing F5.

          Jaume Sola
          tag:blog.jaumesola.com,2013:Post/577257 2013-05-04T12:32:00Z 2015-10-08T11:39:02Z The easy way to convert XML into PDF J4L FO Designer is a productivity tool that helps you to convert XML files into PDF by using Apache FOP, the open and free implementation of the XLS-FO standard.

          As a productivity tool, our product intends to save you a significant amount of your time, and spare you the difficulties of a manual process. As explained in my previous post “How to create PDF files from XML with Apache-FOP”, XSL-FO and Apache-FOP provide a free and standard way to create PDF files in a language independent manner.

          But there are a number of disadvantages with that approach, e.g.:

          • you have to learn XSL-FO (and therefore also XPath and XSL).
          • even if you know XSL-FO you do not want to be writing FO templates using a text editor.
          • there is some logic that cannot be easily defined using XSL-FO. For example, grouping of data requires you to use the so called Muenchian method , which isn't straightforward to understand.

          In order to overcome these drawbacks, at J4L Components we have developed J4L FO Designer. The designer is a Visual (WYSIWYG) editor that will generate XSL-FO files for you. This makes the start into the XSL-FO world very easy, and it is also a useful tool for experienced developers since you can create and test XSL-FO files very quickly.

          Additionally, it will also implement the algorithms for data grouping and running subtotals. Even though the tool has been created and tested for Apache FOP, the generated XSL-FO files would work with other FOP implementations.

          Last but not least, we have added additional features to the FOP server (this is outside the standard) such as digital signatures and creation of PDF interactive forms.

          You can download the evaluation version here.


          In the previous post we have seen how to create a "Hello World" PDF file by using XSL-FO files. The following instructions explain how the same PDF file can be created using J4L FO Designer:

          1) We use the same persons.xml file:

          <?xml version="1.0"?>





          2) Open the designer, select the "Test Data" section on top of the left column and load persons.xml

          the content of the file will be shown in the tool

          3) We will now create an XML schema. In the XML schema you will see the structure of your file. Select the "XML Schema" section on the left column then use also the persons.xml file to create it on the fly.
          4) In the next step we associate the detail section to the /persons/person node, so we will get one line for each person. Click on the Detail area header, then set XML node property to /persons/person.
          5) As last step we add a field in the detail area. Click on the "Aa" button on top to select the field tool, then click somewhere in the detail area to add the field there. Finally we set the Xpath property. In this example we use the concat function to concatenate the text ‘Hello’ and the name of the current person (this could also be done with two separate fields):
          6) Click on the PDF button
          and the report.pdf file will be created.
          Jaume Sola
          tag:blog.jaumesola.com,2013:Post/235611 2013-03-19T11:39:24Z 2016-07-24T20:40:16Z Usar Gmail para cuentas de correo que no son de Google.

          Este procedimiento sirve para cuando tenemos una cuenta de Gmail y queremos usar Gmail como servicio para gestionar otras cuentas que no son de Google, sin tener que decir a nuestros contactos que hemos cambiado de correo. Es decir para nuestros contactos no cambia nada: siguen usando nuestra dirección de correo que conocen. Para nosotros cambia que usamos el servicio de Gmail para gestionar este correo y, aunque sigue activo, ya no necesitamos usar el servicio del proveedor original.

          Repitiendo este procedimiento se pueden integrar varias cuentas externas en una ÚNICA cuenta gratuita de Gmail. También se puede repetir usando varias cuentas independientes de Gmail gratuito. Si se desea un servicio unificado para la gestión de diversas cuentas de una organización con Gmail, deberá contratarse el servicio de pago "Google Apps".


          1. Tener una cuenta de Gmail
          2. Tener otra cuenta de correo que queremos utilizar con Gmail (cuenta externa)
          3. Que la cuenta de correo externa admita redirección o reenvío automático de todos los mensajes recibidos
          4. Disponer de los datos conexión SMTP segura (TLS ó SSL) que funcione con esta cuenta (servidor, puerto, usuario, contraseña)


            1. Obtener los datos de conexión de nuestra cuenta externa y averigüar cómo activar la redirección de correos entrantes. Esto puede estar disponible a través de un panel de control o bien tendremos que contactar con nuestro proveedor.

            2. En nuestra cuenta de Gmail realizaremos los siguientes pasos:
              • Entrar en la configuración de la cuenta

              • Clic en Cuentas y en el apartado "Enviar mensaje como" , clicar en Añadir otra dirección de correo tuya

              • En la ventana emergente introducir:
                • Nombre del remitente que se desea usar al enviar mensajes con la cuenta externa
                • La cuenta de correo externa
                • IMPORTANTE: desmarcar la casilla "tratar como un alias"
                • Clicar en botón "paso siguiente"
                • "Enviar el correo a través de tu servidor SMTP
                    • Introducir los datos correspondientes y clicar el botón "Añadir cuenta".
                    • En caso de problemas comprobar que los datos son correctos / consultar el proveedor de nuestro correo.

                  • Verificar tu dirección de correo electrónico
                    • Clicar en botón "Enviar Verificación"
                  • Espera a que te llegue el correo de verificación e introduce el código.
                  • Se cierra la ventana y se actualiza la página de configuración con la nueva cuenta externa añadida. Haz clic ahora en el enlace correspondiente "establecer como predeterminada" junto a la cuenta que acabas de añadir. 
                  • Resultado final:
                • A partir de este momento, al redactar un correo nuevo aparecerá tu cuenta externa como remitente en vez de la de Gmail. Si en algún caso quieres usar la de Gmail podrás desplegar el campo del remitente y elegirla.
                • Activar la redirección de nuestro correo externo al correo de gmail

                • Comprobar con otra cuenta que el envío y recepción funcionan correctamente: enviar un correo desde gmail, comprobar que se recibe con el remitente correcto, responderlo y comprobar que la respuesta llega a nuestra cuenta de gmail

                Jaume Sola
                tag:blog.jaumesola.com,2013:Post/235613 2013-02-06T10:35:47Z 2013-10-08T16:11:44Z New J4L FOP Server professional edition - run as a Windows service We have a new product, an improvement over the free FOP server, an optional companion product to J4L FO Designer.

                The main new feature is that it can be run as a Windows service, and therefore is more suitable for production environments. As a commercial product it also includes 6 months support.

                Relevant links:
                J4L FOP Server
                J4L FOP Server versions
                J4L FO Designer
                Purchase J4L FO Designer / J4L FOP Server Professional]]>
                Jaume Sola
                tag:blog.jaumesola.com,2013:Post/235614 2011-10-12T18:42:00Z 2016-02-10T12:21:42Z How to create PDF files from XML using Apache-FOP


                Nowadays, XML is the native format of many applications, Oracle APEX for example, partly bases its reporting systen on XML. Middleware as Oracle BPEL, SAP PI, IBM Websphere and of course many Web services are also XML based. XML is also being used as exchange format in business to business transactions, for example for e-Invoicing. In these and many other environments there is often the need to create PDF files from XML.


                In the past PDF files would be created using proprietary reporting tools that would use a database as data source. Additionally these tools are programming language specific. Later on the XSL-FO standard allowed for a better way to do it in many cases.

                What is new about XSL-FO?
                - it is programming language neutral.
                - it is a standard so you are not tied to a vendor.
                - it uses XML as data source.

                Apache FOP

                One implementation of the XSL-FO standard is Apache FOP. One important aspect about this implementation is that the Apache license model allows to use it in commercial environment.

                Many free/open source products have a license model that puts strong restrictions on the way you may use the software. Not surprisingly there are software companies that do not allow the use in their code any open source software other than Apache Foundation one. So if you use Apache you know you are on the safe side.


                Once you have installed Apache-FO, let's see how we can create a very simple PDF file. Initially we will use the file hello.fo for this. The output will contain the lines “Hello John” and “Hello Mary”. It is not the the aim of this article to present XSL-FO language in detail, there is a good tutorial here,  but you can see the hight level structure is made of the document layout (red lines) and the page content (blue lines). 

                File hello.fo:

                <?xml version="1.0" encoding="UTF-8"?> 
                <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 

                <fo:simple-page-master margin-right="2cm" margin-left="2cm" margin-bottom="1cm" margin-top="0.5cm" font-family="sans-serif" page-width="21cm" page-height="29.7cm" master-name="main">

                <fo:region-body margin-bottom="1cm" margin-top="4.0cm"/>
                <fo:region-before extent="1.5cm"/>


                <fo:page-sequence master-reference="main">
                <fo:flow flow-name="xsl-region-body">
                <fo:block>Hello John</fo:block>
                <fo:block>Hello Mary</fo:block>




                Using Apache FOP command line utility you can convert this file to PDF. For instance:

                fop hello.fo hello.pdf

                You could automatically create the file hello.fo by different means, however the recommended way to create this file is by putting the data (persons’ names) in a XML file like for example this one:

                File persons.xml:

                <?xml version="1.0"?>





                ...and then creating a XSLT (XSL transformation) which takes the XML data as input and composes the hello.fo file.

                File hello.xsl:

                <?xml version="1.0" encoding="iso-8859-1"?>

                <xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

                <!-- Page layout information -->

                <xsl:template match="/">
                <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

                <fo:simple-page-master master-name="main" page-height="29.7cm" page-width="21cm" font-family="sans-serif" margin-top="0.5cm" margin-bottom="1cm" margin-left="2cm" margin-right="2cm">
                <fo:region-body margin-top="4.0cm" margin-bottom="1cm" />
                <fo:region-before extent="1.5cm" />


                <fo:page-sequence master-reference="main">
                <fo:flow flow-name="xsl-region-body" >
                <xsl:apply-templates select="persons/person" />



                <xsl:template match="persons/person">

                Hello <xsl:value-of select="name" />




                With these two files, the Apache FOP command to create the PDF file would be:

                fop -xml persons.xml -xsl hello.xsl -pdf hello.pdf

                This command is performing 2 steps in one call:

                • Processing the XSLT to create the FO file
                • Creating the PDF from the FO file

                As we have seen, if your data native format is XML, you can create user friendly PDF files with no programming. This is vendor independent and it is being used today in many situations and products.

                With this procedure you are however involved with XSLT and XSL-FO languages and files, which you may prefer to avoid learning and mastering. If that is your case you may be interested in my related post The easy way to convert XML into PDF.

                Jaume Sola
                tag:blog.jaumesola.com,2013:Post/235615 2011-09-20T00:10:00Z 2013-10-08T16:11:44Z J4L Barcodes 1D for Ruby

                I was intrigued about all the buzz around the Rails framework and the Ruby language, so I thought it was the time to check it out by myself and start by learning Ruby. So, as I usually do, I assigned myself some specific learning task: in this case porting the J4L barcoding software from PHP (which in turn was ported from Java).

                Here's the result
                (only 1D barcodes at the moment)

                From a commercial point of view, I wonder if this product will work well because there are already some open source solutions, most notably Barby, and the Ruby community appears to be very focused on open source and have do-it-yourself attitude.

                If you're a Rubist and have considered to use this product and/or some other alternative, I'd appreciate your thoughts. These are the advantages that I think this product offers, compared to Barby:

                • Most importantly, you don't need to struggle to make this component work: it should work out of the box and if it doesn't you will have direct support from me.
                • Low non-Ruby requirements: only the GD libray
                • More complete feature set:
                  • More supported symbologies
                  • It generates not only the barcode itself but also the "human readable interpretation", this is, the text/code in plan ASCII characters below (or above) the bars.
                  • You can specify: bar measures, margins, colors, and other parameters for the graphic output.
                  • Better support of the symbologies characteristics.
                    • For instance length optimization: in Code 128 (and GS1-128) it will select the appropiate code set (A, B or C) and switch between them in order generate the shortest possible symbol, depending on the data to be encoded. In Barby you have to pre-select a code set that will be used for all the data.
                    • Or in GS1-128, J4L Barcodes will recognize the "Application Identifiers" and interpret the data accoding to their length as per specification. E.g. "11654321" will show as "(11)654321", this is A.I. 11, data 654321.
                Jaume Sola
                tag:blog.jaumesola.com,2013:Post/235616 2010-12-01T19:57:00Z 2017-03-08T10:35:36Z Money transfer adventure

                During 2010 I worked mostly on this project. J.M.E., the web designer, and I worked with Iker Marcaide to develop the first version of the international money transfer web application, which was launched around June, just in time to win the "HiT Barcelona global technological innovation summit". 

                As clients started requesting transfers we refined the user interface until October, moment at which the result was compelling enough for investors to pour into the project its first million dollar funding.

                Until this point the service was a generic person-to-person money transfer service. With the new investment and subsequent hiring of the first group of employees, the business focus specialized on tuition payments, and a new application was started with a very different workflow.

                This initial web application was developed using the Zend Framework.

                It was very exciting to participate in this project and contribute to its early success!

                Jaume Sola
                tag:blog.jaumesola.com,2013:Post/235617 2009-01-01T20:00:00Z 2013-10-08T16:11:44Z A few things that I do or did
                • WebbyFiles is one of my own projects. What is it?. Discover by yourself: enter the demo and waste some of your time playing with it in the “Tests” folder.
                • In recent years I worked in the development of the server software that provides content to the TomTom HOME desktop software . If you have a TomTom, it’s quite likely that you have been using this software to manage and update your device. If you did, know that millions have done so, but from now on you’re part of the selected group that know that I did something for them!.
                • I occasionally develop web sites, this is one that I’m proud of, in collaboration with a friend graphical designer.
                • Besides my own software, I also distribute software from others. Most of it is under the J4L components brand. Of those, I ported all barcoding components from Java to PHP. These are: multiple 1D barcodes, PDF147, DataMatrix, MaxiCode, AztecCode and QRCode (you have on-line demos of them all).
                Jaume Sola
                tag:blog.jaumesola.com,2013:Post/235618 1999-01-01T20:00:00Z 2013-10-08T16:11:44Z Boring bored post

                Let's be clear about this: this post is not for humans. Seriously, if you are human and reached this point please stop reading here, as this post is only for robots, thank you.

                Dear Slurp: I love the way you transverse my web site. Nobody does it like you and most importantly, nobody does it so often. You know? whenever I check my web site's statistics, the first thing that I look at are your Gigabytes. You always have at least two full Gigabytes, sometimes even three!. You are unique and I promise you: I will never ever look at that stupid "g" bot that only uses Megabytes. Yes, it brings me lots of human visitors and you don't, but my love is with you forever, and you can rest assured that my first monthly Gigabyte will always be reserved for you and only you. No other robot, and even less a human deserves it as no one will ever transverse my site so thouroughly and so timely. That's why I have reserved a few links for you, so boring for humans that none of them will dare to follow, but that you, I know for sure, will do.

                Eat, little beast, eat...


                Jaume Sola