Skip to content

Symfony & Doctrine Mapping problems with MySQL Bigint columns, and how to fix this

In the process of upgrading a Symfony project from version 2 to version 5, I came across an issue with a MySQL table that has a number of BIGINT columns. There had been no issue previously, but after updating to the newer symfony (and doctrine components) mySQL bigint columns were empty/null in my doctrine entities.

After some investigation I came upon this section of the Doctrine manual:

For compatibility reasons this type is not converted to an integer as PHP can only represent big integer values as real integers on systems with a 64-bit architecture and would fall back to approximated float values otherwise which could lead to false assumptions in applications.


To protect symfony apps running on 32 bit systems, Doctrine maps Bigint columns to the string type, and this broke the entity definition I was using, even though my application will only be deployed on 64 bit systems. I think that for most people this is the norm.

There are a few different ways to get around this issue, including type casting from string to integer/integer to string in your getters and setters, but if you have a lot of bigint columns across tables, that probably isn't a great solution. In this article, I present the solution I implemented, which utilizes a Custom Doctrine type to override the built in Doctrine behavior.
Continue reading "Symfony & Doctrine Mapping problems with MySQL Bigint columns, and how to fix this"

docker4lamp - A LAMP Docker development environment

I have made this project (Docker For LAMP) publically available on Github, under the MIT license.

The target user group is php developers who want or need a simple, minimal (yet very current) LAMP development environment. I want this to be friendly to new developers, and a useful alternative to localhost environments like xamp, mamp or wamp.

Ideally it offers the type of convenience and isolation of a vagrant lamp environment except with orchestrated containers. Continue reading "docker4lamp - A LAMP Docker development environment"

Symfony 5.2 and Apache 2.4

Certainly the most convenient way to develop a Symfony 5.x app is to use the symfony server. Eventually however, you may have to deploy the application. For a number of years nginx with php-fpm was the preference for many sysadmins seeking to wring the maximum performance out of a webserver that also has to run php scripts, but there are now simple ways of configuring apache to use php-fpm while achieving comparable performance to nginx.

For example a vhost setting like this one is possible:


<VirtualHost *:80>
    SetEnv ENVIRONMENT "dev"
    <FilesMatch \.php$>
        SetHandler proxy:fcgi://php:9000
        # for Unix sockets, Apache 2.4.10 or higher
    </FilesMatch>
    # Proxy .php requests to port 9000 of the php-fpm container
    DocumentRoot /usr/local/apache2/cms/public
    ServerName cms.mydev.local
    ServerAdmin admin@mydev.local

    <Directory /usr/local/apache2/cms/public>
        DirectoryIndex index.php index.html
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
   
    # Send apache logs to stdout and stderr
    CustomLog /proc/self/fd/1 common
    ErrorLog /proc/self/fd/2
</VirtualHost>
 


Continue reading "Symfony 5.2 and Apache 2.4"

Symfony 5: The Fast Track book and installing a local PHP version that works!

Having backed Fabien Potencier's "Symfony 5: The Fast Track" book on Kickstarter, I received the book a few weeks ago, and had a chance over the weekend to start reading it.

As a Macbook/OSX user, his recommended environment includes a current locally installed version of PHP with a number of php extension libraries. You also need installation of the php standard composer tool, as well as docker. As I have a Macbook running OSX Mojave, I had to take a number of steps to be able to get started following the book and getting a working installation of the guestbook project using the book's recipe. Here's what I did:


Continue reading "Symfony 5: The Fast Track book and installing a local PHP version that works!"

Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'

So you have a private Bitbucket Repo and you want to utilize it in your project composer.json. You may find that when you run the composer install you get an error pulling your private Bitbucket repo with messages about Oauth failure that may include "Invalid OAuth consumer provided"

Continue reading "Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'"

Configure the Atom live server to use Chrome

The free open source Atom text editor from Github is one of several development tools that have gotten a lot of traction in recent years amongst web technology developers looking for an alternative to the big IDE's like Visual Studio, Eclipse or the JetBrains editors.

Atom is aimed at the same niche often filled by Sublime Text, Vim and Notepad++, namely to provide a small self contained code editor able to work on multiple files at a time, and with available plugins that provide programming features like color syntax highlighting, smart indentation and robust search and replace.





Continue reading "Configure the Atom live server to use Chrome"